Files
----/vue.config.js
2025-12-03 09:30:19 +08:00

43 lines
1.3 KiB
JavaScript
Raw Permalink 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.
module.exports = {
// 修正这里evServer → devServer
devServer: {
host: '0.0.0.0',
port: 8080,
open: true,
proxy: {
// 代理所有以 /api 开头的请求
'/api': {
target: 'http://api.sg199.net', // 后端开发服务器地址
changeOrigin: true, // 允许跨域
secure: false, // 如果是 https 接口,需要配置这个参数
ws: true, // 支持websocket
logLevel: 'debug', // 开启调试日志
// 不重写路径,保留 /api 前缀
// 例如:/api/login/login -> http://api.sg199.net/api/login/login
}
},
// 开启代理日志
client: {
logging: 'info',
overlay: {
errors: true,
warnings: false
}
}
},
publicPath: './', // 关键!解决资源路径问题
// 补充关键配置
chainWebpack: config => {
config
.plugin('html')
.tap(args => {
args[0].title = "我的应用"; // 自定义标题
return args;
});
},
// 生产环境配置
productionSourceMap: false, // 关闭sourcemap减小体积
assetsDir: 'static', // 静态资源目录
}