-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwebpack.prod.js
More file actions
48 lines (46 loc) · 1.19 KB
/
webpack.prod.js
File metadata and controls
48 lines (46 loc) · 1.19 KB
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
const webpack = require('webpack');
const merge = require('webpack-merge');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const common = require('./webpack.common.js');
const path = require('path');
const root = __dirname;
module.exports = merge(common, {
entry: {
main: path.resolve(root, 'src/index.js'),
vendor: [
'react',
'react-router-dom',
'react-dom',
'react-autosuggest',
'react-day-picker',
'semantic-ui-react',
'axios'
]
},
output: {
filename: '[name].[chunkhash].js',
path: path.resolve(root, 'dist'),
// publicPath要设置为 ./ 不然打包之后页面显示空白
publicPath: './'
},
devtool: 'source-map',
plugins: [
new CleanWebpackPlugin(['dist']),
new UglifyJSPlugin({
sourceMap: true
}),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor'
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'runtime'
}),
new webpack.HashedModuleIdsPlugin()
]
});