随着项目越来约庞大,致使构建包的时候速度缓慢!vue
首先推荐使用wepback的可视化资源分析工具。如下给出webpack-bundle-analyzer配置【vue-cli构建项目时会自动配置好】
config/index.js文件中webpack
module.exports = { build: { ... // Run the build command with an extra argument to // View the bundle analyzer report after build finishes: // `npm run build --report` // Set to `true` or `false` to always turn it on or off bundleAnalyzerReport: process.env.npm_config_report } ... }
webpack生产环境中 build/webpack.prod.conf.js文件中web
... if (config.build.bundleAnalyzerReport) { var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin webpackConfig.plugins.push(new BundleAnalyzerPlugin()) } ...
分析结果出来了,接下来就能够开始优化啦