添加环境变量

This commit is contained in:
zhangyiming
2020-11-20 08:48:00 +08:00
parent a8ee79a443
commit a111fcc574
5 changed files with 19 additions and 1 deletions

View File

@@ -1,3 +1,12 @@
const dotEnv = require('dotenv')
const path = require('path')
const VUE_APP_ENV = 'development'
const resolve = dir => path.join(__dirname, dir)
const { VUE_APP_PROXY_DOMAIN } = dotEnv.config({
path: resolve(`.env.${VUE_APP_ENV}`)
}).parsed
module.exports = {
alias: {},
// 是否自动在浏览器打开
@@ -18,7 +27,7 @@ module.exports = {
// 反向代理
proxy: {
'/api': {
target: 'http://127.0.0.1:3000',
target: VUE_APP_PROXY_DOMAIN,
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, '')
}