-
Notifications
You must be signed in to change notification settings - Fork 36
/
bundle.config.js
49 lines (47 loc) · 1.66 KB
/
bundle.config.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
var transformHelper = require('../../index.js').transformHelper,
browserify = require('browserify'),
sourceStream = require('vinyl-source-stream'),
isDebug = (process.env.NODE_ENV !== 'production'),
gutil = require('gulp-util');
var mainStream = function (file, done) {
browserify({
// "entries" can either be hard coded or written this way to use the file path.
// Currently this doesn't support multiple entry points. To do that, you must
// implement the full lazypipe chain yourself and use merge-stream to
// collect all files first before passing it to browserify.
entries: [file.path],
debug: isDebug
})
// other custom transforms as desired
//.transform(reactify)
//.require(vendorLibs)
.bundle()
.on('error', function (err) {
// make sure browserify errors don't break the pipe during watch
if (file.bundleOptions.isWatch) {
gutil.log(gutil.colors.red(err.toString()));
this.emit('end');
} else {
throw err;
}
})
.pipe(sourceStream('app.js')) // convert to gulp stream
.pipe(done); // make sure to pipe to the "done" stream
};
module.exports = {
bundle: {
main: {
scripts: './lib/entry.js', // per browserify, will collect all required dependencies
options: {
uglify: ['production'], // uglify the resulting browserify bundle in prod
rev: ['production'], // rev the resulting browserify bundle in prod
transforms: {
scripts: transformHelper.browserify(mainStream)
},
watch: {
scripts: './lib/**/*.js' // watch all scripts for change but only build from main.js
}
}
}
}
};