forked from Codebrahma/cb-react-forms
/
webpack.prod.js
53 lines (51 loc) · 1.17 KB
/
webpack.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
42
43
44
45
46
47
48
49
50
51
52
53
const UglifyJSPlugin = require('uglifyjs-webpack-plugin')
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')
const BundleAnalyzer = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const merge = require('webpack-merge')
const common = require('./webpack.common.js')
const path = require('path')
// Splitchunks configuration.
const splitChunks = {
cacheGroups: {
default: false,
commons: {
test: /[\\/]node_modules[\\/]/,
name: 'vendor_app',
chunks: 'all',
minChunks: 2,
},
},
}
module.exports = merge(common, {
devtool: '',
mode: 'production',
externals: [
'react',
'react-dom',
],
plugins: [
new BundleAnalyzer({
analyzerMode: 'static',
reportFileName: path.resolve(__dirname, 'report.html'),
})
],
optimization: {
minimizer: [
new UglifyJSPlugin({
sourceMap: true,
uglifyOptions: {
compress: {
inline: false
}
}
}),
new OptimizeCSSAssetsPlugin({
cssProcessorOptions: {
preset: ['default', { discardComments: { removeAll: true } }]
}
}),
],
runtimeChunk: false,
splitChunks,
},
})