-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Open
Description
What problem does this feature solve?
Allows to create modern only build. Some applications don't need legacy build.
I guess that could be achieved by proper configuration of browsersrc file, but this solution seems a bit hacky and unintuitive, and I'm not sure if it would work
What does the proposed API look like?
For example
vue-cli-service build --modern="only"
vue-cli-service build --modern --no-legacy
vue-cli-service build --modern-only
DragonI, KubaJastrz, ananthachetan, essenmitsosse, apulliam and 33 more
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
LinusBorg commentedon Jul 10, 2019
It's not "hacky" imho. but the easiest way would be to simply switch your babel config to this:
..which is basically what modern mode does.
jacekkarczmarczyk commentedon Jul 10, 2019
It's indeed simple when you look at it, but not so obvious to come to the solution without diving deeper in the source code. But I guess adding this information in docs near the "There are a few useful flags" in https://cli.vuejs.org/guide/cli-service.html#vue-cli-service-build or (and) here https://cli.vuejs.org/guide/browser-compatibility.html#modern-mode would be fine as well
essenmitsosse commentedon Jul 10, 2019
I was also looking for this today. Unfortunatly the example by @LinusBorg gives me basically the same build as before, where as the modern build from the same project turns out much small. For example with the settings in
babel.config.js
that @LinusBorg postet, Array-spreads are still converted to function calls.jacekkarczmarczyk commentedon Jul 10, 2019
I've just tried it on a simple app with the following results, definitely not the same as standard modern build
essenmitsosse commentedon Jul 30, 2019
I am also wondering why there doesn't seem any other way to setup webpack to output what would be the output of a modern build.
tobyzerner commentedon Nov 6, 2019
Any update on this?
tobyzerner commentedon Nov 6, 2019
Did some digging and found a solution. Pretty much what @LinusBorg suggested, but
polyfills
can't be falsy or it doesn't get used. This is working to generate a modern build for me:alexcroox commentedon Nov 10, 2019
I would like a flag to disable legacy build so I can run both the legacy and modern builds in parallel in my continuous integration/deployment environment. This would help speed up deployments, and overcome challenges where enforced RAM limits are hit in containers when trying to build both modern and legacy at the same time.
praveenpuglia commentedon Jan 24, 2020
This is what my babel.config.js looks like but I am getting error saying
I also tried the fix by @tobyzerner but resulted in same.
praveenpuglia commentedon Jan 24, 2020
Nevermind! Guess I had to move to V4 to make all this work. It does work now! Thanks!
alexcroox commentedon May 13, 2020
Does the suggestion from @LinusBorg or @tobyzerner still modify and inject the dist/index.html with both the
<script type="module"
andnomodule
tags even if run independently?I'm running into enforced RAM limits in my CI/CD containers that I can't control and it's because it's trying to do both modern and legacy builds in one go and I'd like to split them out into 2 separate pipelines.
phil294 commentedon May 29, 2020
@alexcroox
This cannot be solved with a simple configuration flag, as currently, modern build depends on files created previously by the legacy build:
vue-cli/packages/@vue/cli-service/lib/webpack/ModernModePlugin.js
Lines 65 to 66 in 10296ff
No, as that stuff is handled by ModernModePlugin too, and that one only comes into play with
--modern
flag. Above solutions merely imitate babel-preset-app:vue-cli/packages/@vue/babel-preset-app/index.js
Lines 109 to 111 in 55d3375
As you can see, this is dependent on an environment variable...
So another, simpler way to generate a "modern only build" is
VUE_CLI_MODERN_BUILD=1 npm run build
Not sure for how long however, as this env dependent behavior is somewhat weirdchamp, as even Evan admitted last year: #3438 (comment)
alexcroox commentedon May 29, 2020
Thanks for the clarification. Unfortunately I need to serve both modern and legacy in the index.html so it sounds like I won’t be able to separate them into 2 build processes.
awulkan commentedon Jan 20, 2021
I tried this as well, but it still appears to build a legacy version. I would really love to be able to fully turn off the legacy build. Our internal applications only target modern browsers.
wirk commentedon Apr 28, 2021
@awulkan I just used your approach and then simply removed the --modern flag. Works like a charm!
DevinWell1ee commentedon Jul 21, 2021
how build legacy only ?
DevinWell1ee commentedon Jul 21, 2021
want to build legacy only
rsweny commentedon Nov 28, 2021
In package.json, editing the browserslist to be only modern browsers, ie ["last 2 versions and not dead"], and then removing the --modern flag builds only one set of the js files and these files are identical to what the modern flag outputs.
AceLing commentedon Feb 17, 2022
First, modify .browserslistrc:
Then, execute npm run build and CMD output:
Finally, I get "modern only build"!!!
jeth318 commentedon Mar 25, 2022
The "not ie 11" solved it for me. Thanks.
SherinBloemendaal commentedon May 30, 2022
Yes exactly, the "not ie 11" solved it.