-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
44 lines (40 loc) · 1.21 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
var gulp = require('gulp');
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var reactify = require('reactify');
var watchify = require('watchify');
var resolutions = require('browserify-resolutions');
var eslint = require('gulp-eslint');
var path = require('path');
var zip = require('gulp-zip');
gulp.task('browserify', function () {
var bundler = browserify({
entries: ['./js/main.jsx'],
paths: ['./node_modules','./js'],
transform: [reactify],
debug: true,
// Required properties for watchify
cache: {}, packageCache: {}, fullPaths: true
}).plugin(resolutions, '*')
.on('time', function (time) {
console.log('Bundle updated in ' + (time / 1000) + 's.');
});
var watcher = watchify(bundler);
var bundle = function () {
watcher
.bundle()
.on('error', function (err) {
console.log(err.toString());
})
.pipe(source('main.js'))
.pipe(gulp.dest('./js/build/'));
};
bundle();
return watcher.on('update', function (filenames) {
filenames.forEach(function (filename) {
console.log(path.relative(__dirname, filename) + ' changed.');
});
bundle();
});
});
gulp.task('default', ['browserify']);