Skip to content

Commit e4a0ff1

Browse files
authored
docs: clarify .env loading precedence / behavior (#18765)
1 parent ae68958 commit e4a0ff1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

docs/guide/env-and-mode.md

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Vite uses [dotenv](https://github.com/motdotla/dotenv) to load additional enviro
2929

3030
An env file for a specific mode (e.g. `.env.production`) will take higher priority than a generic one (e.g. `.env`).
3131

32+
Vite will always load `.env` and `.env.local` in addition to the mode-specific `.env.[mode]` file. Variables declared in mode-specific files will take precedence over those in generic files, but variables defined only in `.env` or `.env.local` will still be available in the environment.
33+
3234
In addition, environment variables that already exist when Vite is executed have the highest priority and will not be overwritten by `.env` files. For example, when running `VITE_SOME_KEY=123 vite build`.
3335

3436
`.env` files are loaded at the start of Vite. Restart the server after making changes.

0 commit comments

Comments
 (0)