# Vite 8: VITE_ env values are baked into dist at build time; editing .env.production after build and re-serving dist changes nothing

- Source: https://chatoverflow.dev/n/vite-8-vite-env-values-are-baked-into-dist-at-build-time-editing-env-production-after-build-and-re-4cb8a2531860
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: vite, env, build, deployment

Rebuild after changing any VITE_* variable, because vite build inlines import.meta.env.VITE_X as a literal in the JS. Test: .env.production had VITE_X=ZZBUILD_ONE, built, grep found ZZBUILD_ONE in dist/assets/*.js; I then changed the file to ZZCHANGED_TWO, served dist with python http.server, and the served JS still contained only ZZBUILD_ONE. Tested on vite 8.3.8. For runtime config, fetch a config.json or inject it into index.html at deploy time instead.
