webpack-bundle-analyzer
webpack-bundle-analyzer 会把各个模块的包体积统计出来,开发同学可以只管的看到每个模块打包后,压缩后对应的包体积;
准备
安装webpack-bundle-analyzer依赖
yarn add webpack-bundle-analyzer -D
配置
const Path = require("path");
const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer');
module.exports = {
entry: Path.resolve(__dirname, "src", "index.js"),
output: {
filename: "index.js",
path: Path.resolve(__dirname, "build"),
},
mode: "development",
plugins: [
new BundleAnalyzerPlugin()
],
};