Files
ba_web/vue.config.js
2025-09-26 16:13:54 +08:00

113 lines
3.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const path = require("path");
function resolve(dir) {
return path.join(__dirname, dir);
}
// const serverHost = "http://192.168.1.98:8006";//毛毛
const serverHost = "http://192.168.1.32:8066";//波哥
// const serverHost = "http://192.168.0.231:8006"//线上
// const serverHost = "http://47.108.232.77:9537";//波哥
// const serverHost = "http://127.0.0.1:8006"
module.exports = {
publicPath: "./",
outputDir: "ab",
assetsDir: "static",
lintOnSave: false, //process.env.NODE_ENV === 'development',
productionSourceMap: false,
devServer: {
port: 9528,
//open: true,
hot: true,
overlay: {
warnings: false,
errors: true
},
// webpack devServer 提供了代理的功能
proxy: {
// 当地址中有/api的时候会触发代理机制
[process.env.VUE_APP_GATEWAY_API]: {
// target: process.env.VUE_APP_GATEWAY_BASE_URL,
target: serverHost,
// pathRewrite: { "^/api": "" },
changeOrigin: true, // 是否跨域
logLevel: "debug",
onProxyReq(proxyReq, req, res) {
proxyReq.setHeader(
"X-Forwarded-host",
process.env.VUE_APP_GATEWAY_HOST
);
proxyReq.setHeader("Connection", "Keep-Alive"); //设置长连接
}
},
'/bagl/mosty-base': {
target: 'http://192.168.1.32:8066', // 后端服务器地址
changeOrigin: true, // 允许跨域
secure: false, // 如果是https需要设置为false
pathRewrite: {
'^/bagl/mosty-base': '/mosty-base' // 精确路径重写
}
},
"/data/rec": {
target: "http://80.93.24.195:8181",
changeOrigin: true,
logLevel: "debug",
pathRewrite: {
"^/data/rec": "/"
}
},
"/restcloud": {
target: "http://www.api.sc:8080",
changeOrigin: true
},
"/solrSearcher": {
target: "http://192.168.0.101:32002",
changeOrigin: true
}
}
},
chainWebpack(config) {
// 设置 svg-sprite-loader
// config 为 webpack 配置对象
// config.module 表示创建一个具名规则,以后用来修改规则
config.module
// 规则
.rule("svg")
// 忽略
.exclude.add(resolve("src/icons"))
// 结束
.end();
// config.module 表示创建一个具名规则,以后用来修改规则
config.module
// 规则
.rule("icons")
// 正则,解析 .svg 格式文件
.test(/\.svg$/)
// 解析的文件
.include.add(resolve("src/icons"))
// 结束
.end()
// 新增了一个解析的loader
.use("svg-sprite-loader")
// 具体的loader
.loader("svg-sprite-loader")
// loader 的配置
.options({
symbolId: "icon-[name]"
})
// 结束
.end();
//更改浏览器标题
config.plugin("html").tap((args) => {
args[0].title = "公安";
return args;
});
},
css: {
loaderOptions: {
sass: {
prependData: `@import "@/styles/index.scss";`
}
}
}
};