project is too large, the compilation will be very slow. Every time I start a new project, it will climb at the same speed. I cannot help but want to optimize the compilation speed
Analyze the project with speed-measure-webpack-plugin and webpack-bundle-analyzer
Optimization
Cache optimization
hard-source-webpack-plugin, this plug-in provides intermediate caching steps for modules, but the project has to be run twice. The first build time is normal, and the second time can save about 90% of the time.
npm i hard-source-webpack-plugin -D
plugins: [
new HardSourceWebpackPlugin()
]
But there is no independent webpack.config.js file in the project, so it can only be placed in the vue.config.js file, and use chainWebpack to insert the configuration into webpack.
Use cache in the official website
chainWebpack: (config) => {
config.cache(true)
}
Cooperate with HardSourceWebpackPlugin
chainWebpack: (config) => {
config.plugin('cache').use(HardSourceWebpackPlugin)
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。