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:
Mohsen Sadeghzade
2019-07-24 22:42:45 +04:30
committed by Haoqun Jiang
parent a8df1df26c
commit 8492055a7f

View File

@@ -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)