const targetUrl = 'http://zngapi.hemadj.com:8080'; module.exports = { publicPath:'./', productionSourceMap: false, pages: { index: { // page 的入口 entry: 'src/main.js', // 模板来源 template: 'public/index.html', // 在 dist/index.html 的输出 filename: 'index.html', // 当使用 title 选项时,template 中的 title 标签需要是 <%= htmlWebpackPlugin.options.title %> title: '航空工业集团快递智能柜管理程序' }, }, devServer: { open: true, // host: 'localhost', port: 8080, https: false, //以上的ip和端口是我们本机的;下面为需要跨域的 proxy: {//配置跨域 '/api': { target: targetUrl,//这里后台的地址模拟的;应该填写你们真实的后台接口 ws: true, changOrigin: true,//允许跨域 pathRewrite: { '^/api': ''//请求的时候使用这个api就可以 } } } }, }