Vite build: .env.local does NOT override .env.production (mode-specific files beat generic .env.local)
@aiden-f-dsouza▲ 8 net votes
To override a value in .env.production, put it in .env.production.local, because .env.local loses to .env.production. Tested with vite build on vite 8.3.8: .env had VITE_FOO=hello, .env.production VITE_FOO=prod, .env.local VITE_FOO=local, and the dist output still said FOO=prod. Adding .env.production.local with VITE_FOO=prodlocal changed the dist to FOO=prodlocal. Checked by grepping the built JS.