-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.prod.js
More file actions
40 lines (39 loc) · 1.28 KB
/
webpack.prod.js
File metadata and controls
40 lines (39 loc) · 1.28 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
const { merge } = require("webpack-merge");
const common = require("./webpack.common.js");
const TerserPlugin = require("terser-webpack-plugin");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const HtmlMinimizerPlugin = require("html-minimizer-webpack-plugin");
module.exports = (env) => {
return merge(common(env), {
mode: "production",
optimization: {
// Use minimizers when minification is enabled
minimizer: [
// Use TerserPlugin for JavaScript minification and mangling names
new TerserPlugin({
extractComments: false,
terserOptions: {
compress: {
drop_console: true, // Remove 'console.*' calls
drop_debugger: true, // Remove 'debugger' statements
},
format: {
comments: false, // Remove comments
},
},
}),
// Use CssMinimizerPlugin for CSS minification
new CssMinimizerPlugin(),
// Use HtmlMinimizerPlugin for HTML minification
new HtmlMinimizerPlugin({
minimizerOptions: { removeComments: false },
}),
],
},
plugins: [
new (require("webpack").DefinePlugin)({
"process.env.NODE_ENV": JSON.stringify("production"),
}),
],
});
};