You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
If you need to do this in a cross-platform way (e.g. for developer machines and CI builds), I used the package cross-replace to get the environment variable value.
Install: npm install --save-dev cross-replace
package.json
"build": "cross-replace vite build --mode %VITE_MODE%"
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 viaNODE_ENV=production
for a production build andNODE_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 theVITE_MODE
orMODE
environment variable change the mode.Alternative
In order to change
import.meta.env.MODE
, I need a separate commandnpm run build:staging
, or I need to adjust the command I run likenpm run build -- --mode staging
. These workarounds make my CI config more complex than it could be.Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: