前言
github
:webpack-bundle-analyzer
内容
安装
npm i -D webpack-bundle-analyzer
配置
主要涉及两个文件webpack.config.js
和package.json
webpack.config.js
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin module.exports = { plugins: [ new BundleAnalyzerPlugin({ analyzerMode: 'disabled', generateStatsFile: true, }), ], }
package.json
{ "scripts": { "analyz": "webpack --profile --json > stats.json && webpack-bundle-analyzer --port 9090 ./dist/stats.json" }, }
测试
运行命令
npm run analyz
查看结果
学无止境,谦卑而行.