1.固定写法
module.exports = {
devServer: {
proxy:"http://localhost:8080",
port: 8088,
open: true,
},
}
2.可变化写法
const port = process.env.port || process.env.npm_config_port || 8080
module.exports = {
devServer: {
port: port,
open: true,
overlay: {
warnings: false,
errors: true
},
proxy: {
[process.env.VUE_API]: {
target: process.env.VUE_APP_PORT_API,
changeOrigin: true,
pathRewrite: {
['^' + process.env.VUE_API]: ''
}
}
},
},
}
ENV = 'development'
VUE_API = '/api'
VUE_APP_PORT_API = 'http://localhost:3300'