-
Notifications
You must be signed in to change notification settings - Fork 16
/
gulpfile.js
51 lines (46 loc) · 1.91 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'),
path = require('path'),
gutil = require('gulp-util'),
webpack = require('webpack'),
jsTaskGen = function (mode) {
var isProd = mode === 'prod',
doWatch = mode === 'watch',
output = './examples/';
return function () {
return webpack({
entry: {
'part5/part5': './src/examples/part5.js',
'part6/part6': './src/examples/part6.js',
'part7/part7': './src/examples/part7.js',
'part8/part8': './src/examples/part8.js',
'button/button': './src/examples/button.js',
'graphics/graphics': './src/examples/graphics.js',
'graphics-button/graphics-button': './src/examples/graphics-button.js',
'states/states': './src/examples/states.js'
},
watch: doWatch,
module: {
loaders: [{
test: /.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['es2015', 'react']
}
}]
},
plugins: isProd ? [new webpack.optimize.UglifyJsPlugin()] : [],
output: {
path: path.join(__dirname, output),
filename: '[name].' + (isProd ? 'min.js' : 'js')
},
devtool: !isProd && '#inline-source-map'
}, function (err, stats) {
if (err) throw new gutil.PluginError("webpack", err);
gutil.log("[webpack]", stats.toString({}));
});
}
};
gulp.task('js-dev', jsTaskGen('dev', 'web'));
gulp.task('js-prod', jsTaskGen('prod', 'web'));
gulp.task('js-watch', jsTaskGen('watch', 'web'));