-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathwebpack.config.prod.js
More file actions
61 lines (60 loc) · 1.37 KB
/
webpack.config.prod.js
File metadata and controls
61 lines (60 loc) · 1.37 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
49
50
51
52
53
54
55
56
57
58
59
60
61
const { merge } = require("webpack-merge")
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
const TerserPlugin = require("terser-webpack-plugin")
const commonConfig = require("./webpack.config.common")
module.exports = merge(commonConfig, {
mode: "production",
devtool: "source-map",
optimization: {
minimize: true,
minimizer: [new TerserPlugin()],
splitChunks: {
chunks: "all",
minSize: 20000,
minRemainingSize: 0,
minChunks: 1,
maxAsyncRequests: 30,
maxInitialRequests: 30,
enforceSizeThreshold: 50000,
cacheGroups: {
cmsAdmin: {
test: /[\\/]assets[\\/]cms[\\/]/,
minChunks: 2,
priority: -20,
reuseExistingChunk: true,
},
defaultVendors: {
test: /[\\/]node_modules[\\/]/,
priority: -10,
reuseExistingChunk: true,
},
default: {
minChunks: 2,
priority: -20,
reuseExistingChunk: true,
},
},
},
},
module: {
rules: [
{
test: /\.(png|jpg|jpeg|svg|gif)$/,
loader: "file-loader",
options: {
name: "[name].[contenthash:8].[ext]",
outputPath: "/img",
},
},
],
},
plugins: [
// make sure to include the plugin!
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: "[name].[contenthash:8].css",
chunkFilename: "[id].[contenthash:8].css",
}),
],
})