Skip to content

Commit

Permalink
docs: 补充在vue-cli3项目中使用的场景 (#95)
Browse files Browse the repository at this point in the history
* docs: 补充在vue-cli3项目中使用的场景

* docs: 英文文档
  • Loading branch information
donaldshen authored and levy9527 committed Sep 10, 2019
1 parent 6e59ddb commit 7a3fb51
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@ OSS_CUSTOM_DOMAIN=cdn.xxx.com

`dotenv` document reference [https://www.npmjs.com/package/dotenv](https://www.npmjs.com/package/dotenv)

### vue-cli3

vue-cli3 offers an easy solution to replace [process.env](https://cli.vuejs.org/zh/guide/mode-and-env.html#%E6%A8%A1%E5%BC%8F), but it requires a pattern(VUE*APP*\*) to inject in client side. So we need to use `dotenv-webpack`'s solution.

```js
// vue.config.js
const Dotenv = require('dotenv-webpack')
module.exports = {
configureWebpack: {
plugins: [new Dotenv()]
}
}
```

[⬆Back to Top](#table-of-contents)

## Contributing
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,20 @@ OSS_CUSTOM_DOMAIN=cdn.xxx.com

`dotenv` 文档参考 https://www.npmjs.com/package/dotenv

### vue-cli3

vue-cli3 提供了简便的方案替换[环境变量](https://cli.vuejs.org/zh/guide/mode-and-env.html#%E6%A8%A1%E5%BC%8F),但无法在客户端注入。这个场景需要结合`dotenv-webpack`插件。

```js
// vue.config.js
const Dotenv = require('dotenv-webpack')
module.exports = {
configureWebpack: {
plugins: [new Dotenv()]
}
}
```

[⬆ Back to Top](#table-of-contents)

## Contributing
Expand Down

0 comments on commit 7a3fb51

Please sign in to comment.