-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Library mode does not respect the --mode flag #11302
Comments
This is expected in Vite 4. |
Ok, so I set NODE_ENV=development in .env-development. The import.meta.env.PROD value did not change, but .MODE changed to development. So I could use that, but I do not want to have to create .env files in my common packages every time I clone the repo, because I have other values in those .env files that I can not push to GitHub. So I tried around and got this working:
To be honest, I do not even know why it works, because I thought process is a node thing and does not work in the browser. But with that, it uses the --mode flag of the command I run the final package with (the one that uses the common package build output). |
Ah this is a bug. I found the cause.
You can put the secrets in |
Ah, that's the trick, will use that with |
Describe the bug
I'm using the vite library mode in my monorepo to build the common packages between front and backend.
For development I used:
vite build --mode development
and for production:
vite build
After upgrading to vite 4, both commands seem to replace
import.meta.env.PROD
with true, before, it replaced it with false in development mode.The replacement depending on the mode works in non library mode as far as I can tell
Reproduction
https://github.com/juliushuck/vite-issue/settings
Steps to reproduce
I have added the two commands i use in the package.json scripts
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: