Skip to content

Commit

Permalink
Update mode-and-env.md (vuejs#4257)
Browse files Browse the repository at this point in the history
* 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 149b307)
  • Loading branch information
techieforfun authored and haoqunjiang committed Jul 29, 2019
1 parent a8df1df commit 8492055
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/guide/mode-and-env.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8492055

Please sign in to comment.