Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vue.js: How can I prevent `vue-cli-service --modern` from building the legacy bundle?

Modern mode of Vue CLI always builds the two bundles: modern and legacy.

$ 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.

So it takes twice as long than I build the app without --modern option. It's a waste of time when the app is targeted to only modern browsers.

Is there a way to prevent the Vue CLI from creating the legacy bundle?

like image 256
kaorukobo Avatar asked Sep 07 '19 07:09

kaorukobo


People also ask

How do I stop vue server command line?

Try using Ctrl-C instead. It allows the application to gracefully shut down.

Is vue cli still supported?

Vue CLI is now in maintenance mode. For new projects, please use create-vue to scaffold Vite-based projects. create-vue supports both Vue 2 and Vue 3. Also refer to the Vue 3 Tooling Guide for the latest recommendations.

Can you use vue without cli?

Yes. You can add Vue functionality to existing project without Vue CLI. Preferably a project using Webpack as bundler...then it is pretty simple. You need 3 packages: vue@next, @vue/compiler-sfc and vue-loader and add some rule configuration in your webpack.

What is vue-cli-service lint?

vue-cli-service lintLints and fixes files. If no specific files are given, it lints all files in src and tests , as well as all JavaScript files in the root directory (these are most often config files such as babel. config. js or .


1 Answers

You don't need to use --modern flag. Instead, just adjust .browserslistrc like as follows:

last 2 years

Vue CLI's "Modern" mode stands for the mode which builds two bundles -- legacy and modern --, but it does not represent the appropriate way to make your Vue app code "modern". If you want only the modern output, just adjust what browsers are targeted.

See also this comment on the vue-cli issue.

like image 147
kaorukobo Avatar answered Jan 01 '23 22:01

kaorukobo