-
Notifications
You must be signed in to change notification settings - Fork 27
/
webpack.prod.js
54 lines (46 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
const { merge } = require("webpack-merge");
const common = require("./webpack.common.js");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const serverConfig = require("./webpack.server");
const { execSync } = require("child_process");
process.env["NODE_ENV"] = "production";
var currentBranch = "hyperswitch";
const mergeProd = (dashboardAppName, env) => {
console.log("Building", dashboardAppName);
const publicPath = "auto";
let isProduction = process.env["APP_ENV"] === "production";
return merge([
common(dashboardAppName, publicPath),
{
mode: "production",
output: {
publicPath,
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
compress: {
drop_console: true,
},
},
}),
// For webpack@5 you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line
// `...`,
// new CssMinimizerPlugin(),
],
},
},
]);
};
module.exports = (env, _argv) => {
var webpackConfigs = [serverConfig];
console.log("currentBranch", currentBranch);
if (currentBranch.search(/hyperswitch/) != -1) {
webpackConfigs.push(mergeProd("hyperswitch", env));
}
console.log("webpackConfigs", webpackConfigs);
return webpackConfigs;
};