-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
87 lines (73 loc) · 2.76 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
var gulp = require('gulp');
var webpack = require('webpack');
var gutil = require('gutil');
var async = require('async');
var _ = require('lodash');
gulp.task("default", function(callback){
// Default config.
var defaultConfig = require('./webpack.config');
var createPlugins = function(){
return [
new webpack.optimize.OccurenceOrderPlugin({
preferEntry: true
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
source_map : false,
compress : true,
drop_debugger : false,
comments : false,
no_copyright : true,
})
]
}
var externals = {
'_' : '_',
'lodash' : '_',
'_' : 'lodash',
'lodash' : 'lodash',
}
var configs = {};
// Development
var devConfig = _.cloneDeep(defaultConfig);
configs.devConfig = devConfig;
devConfig.debug = true;
devConfig.output.filename = 'Fluxmax.js';
// Dev no lodash
var devNoLodashConfig = _.cloneDeep(devConfig);
configs.devNoLodashConfig = devNoLodashConfig;
devNoLodashConfig.output.filename = 'Fluxmax.nolodash.js';
devNoLodashConfig.externals = externals;
// Production
var prodConfig = _.cloneDeep(defaultConfig);
configs.prodConfig = prodConfig;
prodConfig.output.filename = 'Fluxmax.min.js';
prodConfig.plugins = prodConfig.plugins || [];
prodConfig.plugins = prodConfig.plugins.concat(createPlugins());
// Production no lodash
var prodNoLodashConfig = _.cloneDeep(defaultConfig);
configs.prodNoLodashConfig = prodNoLodashConfig;
prodNoLodashConfig.output.filename = 'Fluxmax.nolodash.min.js';
prodNoLodashConfig.externals = externals;
prodNoLodashConfig.plugins = prodNoLodashConfig.plugins || [];
prodNoLodashConfig.plugins = prodNoLodashConfig.plugins.concat(createPlugins());
async.series(
_.map(configs, function(config, name){
return function(cb){
console.log(name)
webpack(config, function(err, stats) {
console.log('=====')
console.log('=====')
console.log(name)
console.log('-----')
if(err) throw new gutil.PluginError("webpack:build", err);
gutil.log(name, stats.toString({
colors: true
}));
cb();
})
}
}), function(){
console.log('All builds done.')
})
});