如何在Vue.js的vue.config.js中添加devServer配置
合并devServer代理配置到vue.config.js
直接在defineConfig的配置对象中添加devServer属性即可,修改后的完整代码如下:
const { defineConfig } = require('@vue/cli-service') module.exports = defineConfig({ transpileDependencies: true, devServer: { proxy: 'http://localhost:8080/' } })
修改说明
- 无需重新定义
module.exports,直接在原有defineConfig包裹的配置对象内,新增devServer字段并填入你的代理配置 - 注意保持对象内语法正确,属性之间用逗号分隔
内容的提问来源于stack exchange,提问作者Aditya Mahajan
相关产品推荐
相关产品推荐

