TransFlow/vue.config.js

75 lines
2.2 KiB
JavaScript

// module.exports = {
// assetsDir: 'static',
// productionSourceMap: false,
// configureWebpack: {
// devtool: 'source-map'
// }
// // devServer: {
// // proxy: {
// // '/api':{
// // target:'http://jsonplaceholder.typicode.com',
// // changeOrigin:true,
// // pathRewrite:{
// // '/api': ''
// // }
// // }
// // }
// // }
// }
const os = require('os');
///获取本机ip///
function getIPAdress() {
var interfaces = os.networkInterfaces();
for (var devName in interfaces) {
var iface = interfaces[devName];
for (var i = 0; i < iface.length; i++) {
var alias = iface[i];
if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal) {
return alias.address;
}
}
}
}
const myHost = getIPAdress();
module.exports = {
// 打包文件配置
publicPath: "/",
assetsDir: "static",
lintOnSave: false,
devServer: {
// overlay: { // 让浏览器 overlay 同时显示警告和错误
// warnings: true,
// errors: true,
// },
// hotOnly: true,
// open: false, // npm run serve后自动打开页面
// https: false, // https:{type:Boolean}
// host: getNetworkIp(), // 匹配本机IP地址(默认是0.0.0.0)
// port: 8989, // 开发服务器运行端口号
host: myHost,
proxy: {
'/api': { //代理的名字
target: 'http://172.16.1.168:5000/api/',
// target: 'http://172.16.1.178:5001/',
// target: 'http://ht.api.umayle.com:2022',
ws: true,
// host:getNetworkIp(),
changeOrigin: true,
pathRewrite:{
'^/api':'',
}
},
// '/aps': { //代理的名字
// target: 'http://220.163.114.157:5011/',
// // target: 'http://172.16.1.178:5001/',
// // target: 'http://ht.api.umayle.com:2022',
// ws: true,
// changeOrigin: true,
// pathRewrite:{
// '^/aps':'',
// }
// }
}
}
}