-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·86 lines (74 loc) · 1.87 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
var gulp = require('gulp');
var gutil = require('gulp-util');
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var watchify = require('watchify');
var reactify = require('reactify');
var notifier = require('node-notifier');
var server = require('gulp-server-livereload');
var concat = require('gulp-concat');
var sass = require('gulp-sass');
var watch = require('gulp-watch');
var notify = function(error) {
var message = 'In: ';
var title = 'Error: ';
if(error.description) {
title += error.description;
} else if (error.message) {
title += error.message;
}
if(error.filename) {
var file = error.filename.split('/');
message += file[file.length-1];
}
if(error.lineNumber) {
message += '\nOn Line: ' + error.lineNumber;
}
notifier.notify({title: title, message: message});
};
var bundler = watchify(browserify({
entries: ['./src/app.jsx'],
transform: [reactify],
extensions: ['.jsx'],
debug: true,
cache: {},
packageCache: {},
fullPaths: true
}));
function bundle() {
return bundler
.bundle()
.on('error', notify)
.pipe(source('main.js'))
.pipe(gulp.dest('./'))
}
bundler.on('update', bundle)
gulp.task('build', function() {
bundle()
});
gulp.task('serve', function(done) {
gulp.src('')
.pipe(server({
livereload: {
enable: true,
filter: function(filePath, cb) {
if(/main.js/.test(filePath)) {
cb(true)
} else if(/style.css/.test(filePath)){
cb(true)
}
}
},
open: true
}));
});
gulp.task('sass', function () {
gulp.src('./sass/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(concat('style.css'))
.pipe(gulp.dest('./'));
});
gulp.task('default', ['build', 'serve', 'sass', 'watch']);
gulp.task('watch', function () {
gulp.watch('./sass/**/*.scss', ['sass']);
});