Skip to content

Commit

Permalink
docs: add note to use dotenv-expand (#10440) (#10798)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjosue15 committed Nov 6, 2022
1 parent 57916a4 commit 96bd10a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/guide/env-and-mode.md
Expand Up @@ -60,6 +60,17 @@ console.log(import.meta.env.VITE_SOME_KEY) // 123
console.log(import.meta.env.DB_PASSWORD) // undefined
```
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).
Note that if you want to use `$` inside your environment value, you have to escape it with `\`.
```
KEY=123
NEW_KEY1=test$foo # test
NEW_KEY2=test\$foo # test$foo
NEW_KEY3=test$KEY # test123
```
If you want to customize the env variables prefix, see the [envPrefix](/config/shared-options.html#envprefix) option.
:::warning SECURITY NOTES
Expand Down

0 comments on commit 96bd10a

Please sign in to comment.