-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.prod.js
41 lines (39 loc) · 1.13 KB
/
webpack.config.prod.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
const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const ClearWebpackPlugin = require('clean-webpack-plugin');
const baseConfig = require('./webpack.base.js');
const config = {
output: {
filename: '[name].[chunkhash].js',
chunkFilename: '[name].[chunkhash].js',
path: path.resolve(__dirname, 'dist')
},
devtool: 'source-map',
plugins: [
new ClearWebpackPlugin(['dist']),
// 提取 vendor
// https://doc.webpack-china.org/guides/caching/#-extracting-boilerplate-
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: function(module) {
return module.context && module.context.indexOf('node_modules')!==-1;
}
}),
// 稳定 vendor hash
new webpack.optimize.CommonsChunkPlugin({
name: "manifest",
chunks: ['vendor']
}),
new UglifyJSPlugin({
sourceMap: true
}),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
})
],
};
module.exports = merge(baseConfig, config);