Skip to content

Commit 7282629

Browse files
committed
adjust Webpack
1 parent abb8f01 commit 7282629

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

webpack.config.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import path from "path";
22

33
import HtmlWebpackPlugin from "html-webpack-plugin";
4+
import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer";
45
import webpack from "webpack";
56

67
export default async (env, options) => {
78
const dev = options.mode === "development";
89
const config = {
910
optimization: {
10-
minimize: false,
11+
minimize: !dev,
12+
splitChunks: {
13+
chunks: "all",
14+
},
1115
},
1216
devtool: dev ? "source-map" : false,
1317
entry: "./js/ispy.js",
@@ -47,6 +51,14 @@ export default async (env, options) => {
4751
}),
4852
],
4953
};
50-
54+
if (env && env.analyze) {
55+
config.plugins.push(
56+
new BundleAnalyzerPlugin({
57+
analyzerMode: "static", // generates a file
58+
openAnalyzer: true, // opens the report in browser
59+
reportFilename: path.resolve("dist", "bundle-report.html"),
60+
}),
61+
);
62+
}
5163
return config;
5264
};

0 commit comments

Comments
 (0)