40 lines
1.4 KiB
JavaScript
40 lines
1.4 KiB
JavaScript
import { defineConfig } from 'vite'
|
||
import vue from '@vitejs/plugin-vue'
|
||
import path from 'node:path'
|
||
|
||
// Vite 构建配置
|
||
// docs: https://vitejs.dev/config/
|
||
export default defineConfig({
|
||
plugins: [vue()],
|
||
resolve: {
|
||
// 路径别名 @ -> src
|
||
alias: {
|
||
'@': path.resolve(__dirname, 'src')
|
||
}
|
||
},
|
||
server: {
|
||
port: 5173,
|
||
// 开发代理:前端请求转发到后端 Spring Boot(port 8081, context-path /laop)
|
||
proxy: {
|
||
// 后端静态资源(图片、文件):前端浏览器直接访问 /static/xxx,代理到后端 /laop/static/xxx
|
||
'/static': {
|
||
target: 'http://localhost:8081',
|
||
changeOrigin: true,
|
||
rewrite: (path) => path.replace(/^\/static/, '/laop/static')
|
||
},
|
||
// 文件上传接口:保留 /api 前缀不变(后端实际是 /api/file/upload)
|
||
'/api/file': {
|
||
target: 'http://localhost:8081',
|
||
changeOrigin: true,
|
||
rewrite: (path) => path.replace(/^\/api/, '/laop/api')
|
||
},
|
||
// Web 管理端其余接口:/api/* → /laop/*
|
||
'/api': {
|
||
target: 'http://localhost:8081',
|
||
changeOrigin: true,
|
||
rewrite: (path) => path.replace(/^\/api/, '/laop')
|
||
}
|
||
}
|
||
}
|
||
})
|