-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
51 lines (44 loc) · 1.26 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
/**
* Gulpfile for task running
* @author Kaanon MacFarlane <@thekaanon>
*/
var gulp = require('gulp');
var gutil = require('gulp-util');
var webpack = require('webpack');
var fs = require('fs');
var configFile = process.cwd() + '/webpack.config.js';
if (!fs.existsSync(configFile)) {
console.error('No webpack config found');
return;
}
var webpackConfig = require(configFile);
gulp.task('webpack:build', function(callback) {
webpackConfig.plugins = (webpackConfig.plugins || []).concat(
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: 'production'
}
}),
new webpack.optimize.UglifyJsPlugin()
);
var compiler = webpack(webpackConfig);
webpack(webpackConfig).run(function(err, stats) {
if (err) {
throw new gutil.PluginError('webpack:build', err);
}
gutil.log('[webpack:build]', stats.toString({
colors: true
}));
callback();
});
});
gulp.task('webpack:watch', function() {
webpack(webpackConfig).watch(100, function (err, stats) {
if (err) {
throw new gutil.PluginError('webpack:watch', err);
}
gutil.log('[webpack:build]', stats.toString({
colors: true
}));
});
});