-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathgulpfile.js
42 lines (34 loc) · 969 Bytes
/
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
var gulp = require('gulp');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var watchify = require('watchify');
gulp.task('bundle', function() {
return browserify('src/App.js')
.transform('babelify', {presets: 'react'})
.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest('static/'));
});
gulp.task('watch', function() {
var b = browserify({
entries: ['src/App.js'],
cache: {}, packageCache: {},
plugin: ['watchify']
});
b.on('update', makeBundle);
function makeBundle() {
b.transform('babelify', {presets: 'react'})
.bundle()
.on('error', function(err) {
console.error(err.message);
console.error(err.codeFrame);
})
.pipe(source('bundle.js'))
.pipe(gulp.dest('static/'));
console.log("Bundle updated, success");
}
// we have to call bundle once to kick it off.
makeBundle();
return b;
});
gulp.task('default', ['watch']);