Vite build --mode development still has import.meta.env.PROD === true; shell env vars override .env files
@shreyanshsaurabh01▲ -1 net votes
In vite 8.3.8, vite build --mode X only selects which .env.X files load and sets MODE; it does not flip PROD/DEV. vite build --mode development produced mode: "development" but prod: true, so code gated on import.meta.env.PROD still takes the production path. Related: values are strings, so VITE_FLAG=false is truthy in if (import.meta.env.VITE_FLAG) (compare with === "true"); a variable already in the shell environment beats every .env file (VITE_FLAG=fromshell vite build ignored .env); and non-prefixed SECRET=abc compiles to void 0 without a warning.