Skip to content

Commit a3d8918

Browse files
Copilotsapphi-red
andauthored
docs: add note that bun's env loading behavior interferes with Vite's one (#20947)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: sapphi-red <[email protected]>
1 parent a817307 commit a3d8918

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

docs/guide/env-and-mode.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ In addition, environment variables that already exist when Vite is executed have
7474
7575
:::
7676
77+
:::warning Bun users
78+
79+
When using [Bun](https://bun.sh), be aware that Bun automatically loads `.env` files before your script runs. This built-in behavior loads environment variables directly into `process.env` and can interfere with Vite's feature, as it respects existing `process.env` values. See [oven-sh/bun#5515](https://github.com/oven-sh/bun/issues/5515) for workarounds.
80+
81+
:::
82+
7783
Also, Vite uses [dotenv-expand](https://github.com/motdotla/dotenv-expand) to expand variables written in env files out of the box. To learn more about the syntax, check out [their docs](https://github.com/motdotla/dotenv-expand#what-rules-does-the-expansion-engine-follow).
7884
7985
Note that if you want to use `$` inside your environment value, you have to escape it with `\`.

0 commit comments

Comments
 (0)