当我们使用CommonsChunkPlugin插件时可以使用webpack-bundle-analyzer插件来分析分块是否达到我们的目地
安装
npm install --save-dev webpack-bundle-analyzer
使用
在webpack.config.js里的plugins里加
module.exports = { plugins: [ new BundleAnalyzerPlugin() ] }
最后命令行启动
webpack --profile --json > stats.json
如果你是vue-cli 就使用
npm run build --report
This module will help you:
- Realize what's really inside your bundle
- Find out what modules make up the most of its size
- Find modules that got there by mistake
- Optimize it!1