vite
vite copied to clipboard
Allow setting mode via environment variable
Description
I am used to being able to configure my builds in CI via environment variables. E.g., if I have npm run build
I would like to be able to use that same command, but have it behave differently based on the environment. Currently I can somewhat affect my build via NODE_ENV=production
for a production build and NODE_ENV=development
for a staging build. I would like to have the same control for the mode.
Suggested solution
Similarly to NODE_ENV
we could have the VITE_MODE
or MODE
environment variable change the mode.
Alternative
In order to change import.meta.env.MODE
, I need a separate command npm run build:staging
, or I need to adjust the command I run like npm run build -- --mode staging
. These workarounds make my CI config more complex than it could be.
Additional context
No response
Validations
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guidelines.
- [X] Read the docs.
- [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.