-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathwebpack.config.production.js
54 lines (50 loc) · 1.25 KB
/
webpack.config.production.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
var config = require("./webpack.config");
var path = require("path");
var webpack = require("webpack");
var HtmlWebpackPlugin = require("html-webpack-plugin");
var ExtractTextPlugin = require("extract-text-webpack-plugin");
/**
* Define global application variables.
*/
var definePlugin = new webpack.DefinePlugin({
__DEV__: JSON.stringify(false),
"process.env": {
NODE_ENV: JSON.stringify("production")
}
});
/**
* Output configuration for production.
*/
config.output = {
path: path.resolve("./build"),
filename: "[name].min.js",
publicPath: ""
};
/**
* Add production specific plugins to the common ones.
*/
config.plugins = config.commonPlugins.concat([
definePlugin,
new ExtractTextPlugin("[name].min.css", {
allChunks: true
}),
new webpack.optimize.CommonsChunkPlugin({
name: "vendor",
path: "[name].min.js",
minChunks: function (module, count) {
return module.resource && module.resource.indexOf(path.resolve('node_modules')) !== -1;
}
}),
new webpack.optimize.OccurenceOrderPlugin(true),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
},
sourceMap: false
}),
]);
/**
* Export the configuration object.
*/
module.exports = config;