This repository has been archived by the owner on Nov 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
webpack.prod.js
55 lines (54 loc) · 1.46 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
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const { merge } = require('webpack-merge');
const DefinePlugin = require('webpack/lib/DefinePlugin');
const common = require('./webpack.common.js');
module.exports = merge(common, {
mode: 'production',
plugins: [
new DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
},
}),
new MiniCssExtractPlugin({
filename: '[name].[fullhash].css',
chunkFilename: '[id].[fullhash].css',
}),
/*
* Plugin: CleanWebpackPlugin
* Description: A webpack plugin to remove/clean your build folder(s).
* See: https://github.com/johnagan/clean-webpack-plugin
*/
new CleanWebpackPlugin(),
],
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
},
styles: {
name: 'styles',
test: /\.css$/,
chunks: 'all',
enforce: true,
},
},
},
minimize: true,
minimizer: [
/*
* Plugin: TerserWebpackPlugin
* Description: This plugin uses terser to minify your JavaScript.
* See: https://webpack.js.org/plugins/terser-webpack-plugin
*/
new TerserPlugin({
parallel: true,
}),
],
},
});