-
Notifications
You must be signed in to change notification settings - Fork 10
/
webpack.config.js
95 lines (90 loc) · 2.76 KB
/
webpack.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
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
88
89
90
91
92
93
94
95
var _ = require('lodash');
var path = require('path');
var webpack = require('webpack');
var config = require('./config');
var StatsPlugin = require('stats-webpack-plugin');
var assign = require('object-assign');
var devOutput = _.extend({},config.output,{publicPath: config.previewUrl+config.assetsFolder+'/'});
if(config.hotReload){
var devEntry = _.reduce(config.entry,function(entries,v,k){
entries[k] = ['webpack-dev-server/client?'+config.previewUrl, 'webpack/hot/dev-server', v];
return entries;
},{});
var devPlugins = [new webpack.HotModuleReplacementPlugin(), new webpack.NoErrorsPlugin()]
} else {
var devEntry = config.entry
var devPlugins = [new webpack.NoErrorsPlugin()]
}
debugOutput = assign({},config.output,{filename: '[name].debug.js',});
var uglifyPlugin = new webpack.optimize.UglifyJsPlugin({
comments: false,
minimize:true,
ascii_only:true,
quote_keys:true,
sourceMap: true,
beautify: false,
compress: {
warnings: false,
drop_console: false,
drop_debugger:false,
dead_code:true,
// comparisons: true,
// conditionals:true
join_vars:true
}
})
module.exports = {
development:{
browser: {
name : 'browser',
devtool : '#source-map',
devServer: true,
entry : devEntry,
output : devOutput,
resolve : {
root: [path.join(__dirname, "bower_components")],
extensions: config.extensions
},
module : {loaders: config.loaders},
plugins: config.plugins.concat([
new webpack.DefinePlugin({'process.env': {'NODE_ENV': JSON.stringify('development') } })
]).concat(devPlugins)
}
},
production:{
browser: {
name : 'browser',
devtool : '#source-map',
entry : config.entry,
output : config.output,
resolve : {
root: [path.join(__dirname, "bower_components")],
extensions: config.extensions
},
module : {loaders: config.loaders},
plugins : config.plugins.concat([
new webpack.DefinePlugin({'process.env': {'NODE_ENV': JSON.stringify('production') } }),
uglifyPlugin,
new webpack.optimize.DedupePlugin(),
new StatsPlugin(path.join(config.outputFolder, 'stats.json'), { chunkModules: true, profile: true })
])
}
},
debug:{
browser: {
name : 'browser',
devtool : '#source-map',
entry : config.entry,
output : debugOutput,
resolve : {
root: [path.join(__dirname, "bower_components")],
extensions: config.extensions
},
module : {loaders: config.loaders},
plugins : config.plugins.concat([
new webpack.DefinePlugin({'process.env': {'NODE_ENV': JSON.stringify('production') } }),
new webpack.optimize.DedupePlugin()
])
}
},
}