Replies: 3 comments 12 replies
-
|
If introducing |
Beta Was this translation helpful? Give feedback.
-
|
I agree with all three of your Problem ideas and your two Others ideas (assuming Rich's clarification) with the one caveat: In Problems
|
Beta Was this translation helpful? Give feedback.
-
|
Just got hit by this problem, took quite a while to find this discussion. Running
export default {
mode: 'development'
}
This behavior change from Are there any options to do a build with |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Partially implemented in #10996
There are a few complications with how these vars interact with each other:
import.meta.env.DEVimport.meta.env.PRODmodeprocess.env.NODE_ENVProblem
resolveConfigit setsprocess.env.NODE_ENVifmodeisproduction, this could be unexpected when running the dev server, build, or both, in parallel or sequentially.Idea: Avoid setting
process.env.NODE_ENVinresolveConfig. Set it elsewhere (continued below).developmentorproductionuntil.envis loaded, because plugins can changeenvDir&modein theconfighook. However this cause a second issue since some plugins need to know eitherdevelopmentorproductionbefore theconfighook. (e.g.@vue/compiler-*)Idea: Let the user set
process.env.NODE_ENVthemselves. Ifundefined, auto-setdevelopmentinvite dev,productioninvite build(regardless ofmode) in the CLI (orcreateServer/build?)Also remove the
NODE_ENVconfiguration in.envfiles as it's unused.modeother thanproduction, Vite builds for development, which may not be a good fallback. (Though this is documented)Idea: Relying on idea no2 which should solve this, also set
import.meta.env.DEV = process.env.NODE_ENV !== 'production'andimport.meta.env.PROD = process.env.NODE_ENV == 'production'instead.Others
import.meta.env.COMMANDif users want to differentiate between that specifically.command === 'preview'when callingvite previewRelated issues
import.meta.env.DEVandPRODare incorrect if a custommodeis provided programmatically #9203 (comment)Beta Was this translation helpful? Give feedback.
All reactions