Skip to content

Commit 96bd10a

Browse files
authored
docs: add note to use dotenv-expand (#10440) (#10798)
1 parent 57916a4 commit 96bd10a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

docs/guide/env-and-mode.md

+11
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@ console.log(import.meta.env.VITE_SOME_KEY) // 123
6060
console.log(import.meta.env.DB_PASSWORD) // undefined
6161
```
6262
63+
Also, Vite uses [dotenv-expand](https://github.com/motdotla/dotenv-expand) to expand variables 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).
64+
65+
Note that if you want to use `$` inside your environment value, you have to escape it with `\`.
66+
67+
```
68+
KEY=123
69+
NEW_KEY1=test$foo # test
70+
NEW_KEY2=test\$foo # test$foo
71+
NEW_KEY3=test$KEY # test123
72+
```
73+
6374
If you want to customize the env variables prefix, see the [envPrefix](/config/shared-options.html#envprefix) option.
6475
6576
:::warning SECURITY NOTES

0 commit comments

Comments
 (0)