安装
npm install --save-dev webpack-bundle-analyzer
yarn add -D webpack-bundle-analyzer
配置
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const path = require('path');
const rootPath = path.join(__dirname);
module.exports = {
entry: {
main: `${rootPath}/src/index.js`,
},
output: {
filename: '[name].[hash].js',
path: `${rootPath}/dist`,
},
plugins: [
new BundleAnalyzerPlugin()
]
}
运行
./node_modules/.bin/webpack --config webpack.config.js --progress
webpack --config webpack.config.js --progress