Files
schoolNews/schoolNewsWeb/vue.config.js
2025-10-07 13:31:06 +08:00

46 lines
1.2 KiB
JavaScript

import { defineConfig } from '@vue/cli-service'
export default defineConfig({
transpileDependencies: true,
publicPath: '/schoolNewsWeb/',
outputDir: 'dist',
assetsDir: 'static',
chainWebpack: (config) => {
// 设置环境变量
config.plugin('define').tap((definitions) => {
Object.assign(definitions[0], {
'process.env.BASE_URL': JSON.stringify('/schoolNewsWeb/'),
'process.env.VITE_API_BASE_URL': JSON.stringify('/api'),
'process.env.VITE_APP_TITLE': JSON.stringify('校园新闻管理系统'),
})
return definitions
})
// 设置静态资源路径
config.output.set('publicPath', '/schoolNewsWeb/')
},
devServer: {
host: '0.0.0.0',
port: 8080,
open: true,
hot: true,
historyApiFallback: {
rewrites: [
{ from: /^\/schoolNewsWeb/, to: '/schoolNewsWeb/index.html' }
]
},
proxy: {
'/api': {
target: 'http://127.0.0.1:8081/schoolNewsServ',
changeOrigin: true,
pathRewrite: { '^/api': '' },
logLevel: 'debug',
onProxyReq: (proxyReq, req, res) => {
console.log('代理请求:', req.method, req.url, '->', proxyReq.path);
}
}
}
}
})