-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.prod.js
65 lines (64 loc) · 1.77 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
54
55
56
57
58
59
60
61
62
63
64
65
const path = require('path')
const merge = require('webpack-merge')
const HtmlPlugin = require('html-webpack-plugin')
const CompressionPlugin = require('compression-webpack-plugin')
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')
const TerserPlugin = require('terser-webpack-plugin')
const common = require('./webpack.common.js')
let plugins = [
new HtmlPlugin({
template: "./src/index.html",
excludeChunks: ["base"],
filename: "index.html",
minify: {
collapseWhitespace: true,
collapseInlineTagWhitespace: true,
removeComments: true,
removeRedundantAttributes: true,
},
}),
new CompressionPlugin({
algorithm: 'brotliCompress',
test: /\.(html|js|css|svg|ttf|eot|otf|woff|ico)$/,
compressionOptions: { level: 11 },
threshold: 10240,
minRatio: 0.8,
filename: "[path].br[query]",
test: /\.(html|js|css|svg|ttf|eot|otf|woff|ico)$/,
minRatio: 0.8,
}),
]
module.exports = merge(common, {
mode: 'production',
devtool: false,
optimization: {
splitChunks: {
cacheGroups: {
default: false,
vendors: false,
vendor: {
name: 'vendor',
chunks: 'all',
test: /node_modules/,
priority: 20
},
common: {
name: 'common',
minChunks: 2,
chunks: 'all',
priority: 10,
reuseExistingChunk: true,
enforce: true
}
}
},
minimize: true,
minimizer: [
new TerserPlugin(),
new OptimizeCSSAssetsPlugin({
cssProcessorOptions: { discardComments: { removeAll: true } },
}),
],
},
plugins,
})