-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import.meta.env.MODE=production while import.meta.env.PROD returned false #6302
Comments
so .env had high priority ? |
yes, which is not expected |
Is adding documents better than modifying logic?😀 |
I'm afraid not.It is common practice to use same key name in different env files.The problem here is that |
expect .env had low priority ? I think just exec but |
I think EDIT: From the code, looks like it was intentional. I think we should document instead 🤔 |
Note: The |
I think we also need this PR to make sure |
Describe the bug
When I set
NODE_ENV=development
in .env file, and setNODE_ENV=production
in .env.production file, then runvite build
with production mode(by default), theimport.meta.env.PROD
variable turned out to befalse
, which is expected to betrue
.I found that at
vite/packages/vite/src/node/config.ts
, there is aloadEnv
function, in which process.env.VITE_USER_NODE_ENV would be override by .env filevite/packages/vite/src/node/config.ts
Lines 1012 to 1023 in d856c4b
vite/packages/vite/src/node/config.ts
Line 353 in d856c4b
when vite build, isProduction would be false.
In this case, I think maybe change the condition below may work:
Reproduction
https://github.com/RainKolwa/reproduce-vite-env
System Info
Used Package Manager
pnpm
Logs
Validations
The text was updated successfully, but these errors were encountered: