-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.production.js
74 lines (65 loc) · 1.6 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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,
/**
* Extract all css into one file.
*/
new ExtractTextPlugin("[name].min.css", {
allChunks: true
}),
/**
* Extract all vendor files into a separate file than the our application files.
*/
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;
}
}),
/**
* Check the occurence of modules and assign respective ids.
*/
new webpack.optimize.OccurenceOrderPlugin(true),
/**
* Deduplicate similar code in the output files.
*/
new webpack.optimize.DedupePlugin(),
/**
* Uglify the end files by following the passed options.
*/
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
},
sourceMap: false
}),
]);
/**
* Export the configuration object.
*/
module.exports = config;