-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.prod.js
37 lines (30 loc) · 1.18 KB
/
webpack.config.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
const PACKAGE = require('./package.json');
const HTMLWebpackPlugin = require('html-webpack-plugin')
const webpack = require("webpack");
const sharedConfig = require("./webpack.config.shared.js");
const TerserPlugin = require('terser-webpack-plugin');
sharedConfig.config.mode = "production";
sharedConfig.config.optimization = {
minimize: true,
minimizer: [new TerserPlugin({
terserOptions: {
ecma: 5,
ie8: true,
safari10: true,
compress: { drop_console: true },
output: { comments: false, beautify: false },
},
}),
sharedConfig.defaultCompression],
};
sharedConfig.config.plugins.push(new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify("production"),
}));
sharedConfig.htmlPlugin.userOptions.templateParameters.langCode = undefined;
for (let l of PACKAGE.languages ?? []) {
const templateOptions = JSON.parse(JSON.stringify(sharedConfig.htmlPlugin.userOptions));
templateOptions.templateParameters.langCode = l;
templateOptions.filename = "index." + l + ".html";
sharedConfig.config.plugins.push(new HTMLWebpackPlugin(templateOptions))
}
module.exports = sharedConfig.config;