-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathGulpfile.js
52 lines (45 loc) · 1.33 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
var gulp = require('gulp');
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var watchify = require('watchify');
var reactify = require('reactify');
var babelify = require('babelify');
var nodemon = require('gulp-nodemon');
gulp.task('browserify', scripts)
.task('serve', serve);
function scripts() {
var bundler = browserify({
entries: ['./client/src/main.js'],
// transform: [reactify],
debug: true,
cache: {},
packageCache: {},
fullPaths: true
}).transform("babelify", {presets: ["es2015", "react", "stage-1"]});
var watcher = watchify(bundler);
return watcher
.on('update', function() {
var updateStart = Date.now();
console.log('Updating!');
watcher.bundle()
.on('error', function(err) {
console.log('Error with compiling components', err.message);
})
.pipe(source('bundle.js'))
.pipe(gulp.dest('./client/build/'));
console.log('Updated!', (Date.now() - updateStart) + 'ms');
})
.bundle()
.on('error', function(err) {
console.log('Error with compiling components', err.message);
})
.pipe(source('bundle.js'))
.pipe(gulp.dest('./client/build/'));
}
function serve() {
nodemon({
script: 'server/server.js',
ignore: ['client/']
});
}
gulp.task('default', ['browserify', 'serve']);