-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathwebpack.config.mjs
27 lines (24 loc) · 908 Bytes
/
webpack.config.mjs
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
import process from "node:process";
import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer";
import { merge as webpackMerge } from "webpack-merge";
import webpackCommon from "./webpack.common.mjs";
import webpackDev from "./webpack.dev.mjs";
import webpackProd from "./webpack.prod.mjs";
export default function (env = {}) {
const isProduction = process.env.NODE_ENV === "production";
const commonWebpackConfig = webpackCommon();
if (env.showBundleAnalysis) {
return webpackMerge(commonWebpackConfig, webpackProd(), {
plugins: [
new BundleAnalyzerPlugin({
defaultSizes: "parsed",
openAnalyzer: true,
}),
],
});
}
if (isProduction) {
return webpackMerge(commonWebpackConfig, webpackProd());
}
return webpackMerge(commonWebpackConfig, webpackDev());
}