WebMusic/webapp/vite.config.js

37 lines
779 B
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.

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.htmlSPA 路由支持)
rollupOptions: {
input: {
main: './index.html',
},
},
},
})