mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-01-15 11:50:19 -06:00
Update mode-and-env.md (#4257)
* Update mode-and-env.md
Fixed example of keys, which they should start with VUE_APP_
* Update mode-and-env.md
change position of the tip
* Update docs/guide/mode-and-env.md
Co-Authored-By: Natalia Tepluhina <NataliaTepluhina@users.noreply.github.com>
(cherry picked from commit 149b307f72)
This commit is contained in:
committed by
Haoqun Jiang
parent
a8df1df26c
commit
8492055a7f
@@ -46,6 +46,8 @@ FOO=bar
|
||||
VUE_APP_SECRET=secret
|
||||
```
|
||||
|
||||
Note that only variables that start with `VUE_APP_` will be statically embedded into the client bundle with `webpack.DefinePlugin`.
|
||||
|
||||
For more detailed env parsing rules, please refer to [the documentation of `dotenv`](https://github.com/motdotla/dotenv#rules). We also use [dotenv-expand](https://github.com/motdotla/dotenv-expand) for variable expansion (available in Vue CLI 3.5+).
|
||||
|
||||
Loaded variables will become available to all `vue-cli-service` commands, plugins and dependencies.
|
||||
@@ -82,7 +84,7 @@ In both cases, the app is built as a production app because of the `NODE_ENV`, b
|
||||
|
||||
### Using Env Variables in Client-side Code
|
||||
|
||||
Only variables that start with `VUE_APP_` will be statically embedded into the client bundle with `webpack.DefinePlugin`. You can access them in your application code:
|
||||
You can access env variables in your application code:
|
||||
|
||||
``` js
|
||||
console.log(process.env.VUE_APP_SECRET)
|
||||
|
||||
Reference in New Issue
Block a user