Vue.js:如何防止 `vue-cli-service --modern` 构建遗留包?
Vue.js: How can I prevent `vue-cli-service --modern` from building the legacy bundle?
Modern mode of Vue CLI 始终构建两个包:现代包和传统包。
$ vue-cli-service build --modern
- Building legacy bundle for production...
(snip)
DONE Compiled successfully in 42448ms
(snip)
- Building modern bundle for production...
(snip)
DONE Compiled successfully in 39693ms
(snip)
DONE Build complete. The dist directory is ready to be deployed.
(snip)
Done in 89.76s.
所以它比我在没有 --modern
选项的情况下构建应用程序花费的时间多一倍。如果该应用仅针对现代浏览器,那就是浪费时间。
有没有办法阻止 Vue CLI 创建遗留包?
您不需要使用 --modern
标志。
相反,只需调整 .browserslistrc
如下所示:
last 2 years
Vue CLI 的 "Modern" mode 代表构建两个包的模式——传统的和现代的——但它并不代表制作 Vue 应用程序代码的适当方式 "modern"。
如果您只想要现代输出,只需调整目标浏览器即可。
另见 this comment vue-cli 问题。
Modern mode of Vue CLI 始终构建两个包:现代包和传统包。
$ vue-cli-service build --modern
- Building legacy bundle for production...
(snip)
DONE Compiled successfully in 42448ms
(snip)
- Building modern bundle for production...
(snip)
DONE Compiled successfully in 39693ms
(snip)
DONE Build complete. The dist directory is ready to be deployed.
(snip)
Done in 89.76s.
所以它比我在没有 --modern
选项的情况下构建应用程序花费的时间多一倍。如果该应用仅针对现代浏览器,那就是浪费时间。
有没有办法阻止 Vue CLI 创建遗留包?
您不需要使用 --modern
标志。
相反,只需调整 .browserslistrc
如下所示:
last 2 years
Vue CLI 的 "Modern" mode 代表构建两个包的模式——传统的和现代的——但它并不代表制作 Vue 应用程序代码的适当方式 "modern"。 如果您只想要现代输出,只需调整目标浏览器即可。
另见 this comment vue-cli 问题。