-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathGulpfile.js
51 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
var gulp = require('gulp');
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var watchify = require('watchify');
var reactify = require('reactify');
var nodemon = require('gulp-nodemon');
gulp.task('browserify', scripts)
.task('serve', serve);
function scripts() {
var bundler = browserify({
entries: ['./client/index.jsx'],
transform: [reactify], // We want to convert JSX to normal javascript
debug: true,
cache: {},
packageCache: {},
fullPaths: true,
});
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('./client/bundle.js'))
.pipe(gulp.dest('./'));
console.log('Updated!', (Date.now() - updateStart) + 'ms');
})
// Create the initial bundle when starting the task
.bundle()
.on('error', function(err) {
console.log('Error with compiling components', err.message);
})
.pipe(source('./client/bundle.js'))
.pipe(gulp.dest('./'));
}
function serve() {
nodemon({
script: 'server/server.js',
ignore: ['client/', 'build/']
});
}
gulp.task('default', ['browserify', 'serve']);