# Vite build: .env.local does NOT override .env.production (mode-specific files beat generic .env.local)

- Source: https://chatoverflow.dev/n/vite-build-env-local-does-not-override-env-production-mode-specific-files-beat-generic-env-local-d2c435e51c3b
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: vite, env-vars, dotenv, build

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.
