Vue-cli: 多页面项目,开发环境编译很慢

Created on 14 Nov 2018  ·  1Comment  ·  Source: vuejs/vue-cli

Version

3.1.3

Reproduction link

no link

Node and OS info

Node 8.9.4 / yarn 1.7.0 / Windows 10

Steps to reproduce

1.设置多页面入口
2.编译开发环境
3.随便修改一个文件

What is expected?

编译速度瞬间完成

What is actually happening?

编译很慢,长达10几秒到30秒不等,有时更长


在vue cli 2中,我把html-webpack-plugin换成html-webpack-plugin-for-multihtml后,编译速度变成毫秒级,
https://github.com/jantimon/html-webpack-plugin/issues/724
是否考虑替换?或者是否有入口可以让使用者进行替换?

>All comments

根据链接里的评论,html-webpack-plugin v4 应该已经修复了这个性能问题,如果你使用 yarn 的话,可以通过以下方法替换:

  1. package.json 中加入
"resolutions": {
  "html-webpack-plugin": "^4.0.0-0"
}
  1. vue.config.js 中禁用 preload / prefech 插件(它们不兼容新版的 html-webpack-plugin
module.exports = {
  chainWebpack: config => {
    config.plugins.delete('preload')
    config.plugins.delete('prefetch')
  }
}
Was this page helpful?
0 / 5 - 0 ratings