-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.prod.js
68 lines (66 loc) · 1.59 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
66
67
68
// SPDX-License-Identifier: GPL-3.0
//
// Copyright (c) 2024 LINBIT
//
// Author: Liang Li <liang.li@linbit.com>
const path = require('path');
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
const { stylePaths } = require('./stylePaths');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const TerserJSPlugin = require('terser-webpack-plugin');
module.exports = merge(common('production'), {
mode: 'production',
devtool: false,
optimization: {
minimizer: [
new TerserJSPlugin({}),
new CssMinimizerPlugin({
minimizerOptions: {
preset: ['default', { mergeLonghand: false }],
},
}),
],
splitChunks: {
chunks: 'all',
maxInitialRequests: 3,
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
priority: 20,
},
common: {
name: 'common',
minChunks: 2,
chunks: 'all',
priority: 10,
reuseExistingChunk: true,
enforce: true,
},
},
},
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].[chunkhash].css',
chunkFilename: '[name].bundle.css',
}),
],
module: {
rules: [
{
test: /\.css$/,
include: [...stylePaths],
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
],
},
performance: {
hints: 'warning',
maxEntrypointSize: 512000,
maxAssetSize: 512000,
},
});