Vue.js:如何防止`vue-cli-service --modern`构建旧版捆绑包?

问题描述 投票:0回答:1

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创建旧版捆绑软件?

vue.js webpack deployment build vue-cli
1个回答
0
投票

您不需要使用--modern标志。相反,只需如下调整.browserslistrc

last 2 years

Vue CLI的"Modern" mode代表构建两个捆绑软件的模式-旧版和现代版,但是它不代表使Vue应用程序代码“现代化”的适当方法。如果只需要现代输出,则只需调整目标浏览器即可。

另请参见[v0-cli问题上的this comment

© www.soinside.com 2019 - 2024. All rights reserved.