vite icon indicating copy to clipboard operation
vite copied to clipboard

Allow setting mode via environment variable

Open rschamp opened this issue 8 months ago • 2 comments

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

rschamp avatar Jun 18 '24 15:06 rschamp