37 lines
779 B
JavaScript
37 lines
779 B
JavaScript
import { defineConfig } from 'vite'
|
||
import vue from '@vitejs/plugin-vue'
|
||
|
||
export default defineConfig({
|
||
plugins: [vue()],
|
||
base: './', // 使用相对路径,便于 Electron 打包
|
||
server: {
|
||
port: 5173,
|
||
host: true,
|
||
proxy: {
|
||
// 将 /api 路径代理到后端服务器
|
||
'/api': {
|
||
target: 'http://localhost:7001',
|
||
changeOrigin: true,
|
||
rewrite: (path) => path, // 保持路径不变
|
||
},
|
||
// WebSocket代理
|
||
'/ws': {
|
||
target: 'http://localhost:7001',
|
||
ws: true,
|
||
changeOrigin: true,
|
||
},
|
||
},
|
||
},
|
||
build: {
|
||
outDir: 'dist',
|
||
// 确保所有路由都返回 index.html(SPA 路由支持)
|
||
rollupOptions: {
|
||
input: {
|
||
main: './index.html',
|
||
},
|
||
},
|
||
},
|
||
})
|
||
|
||
|