Files
usa/vite.config.ts
2026-03-03 20:17:38 +08:00

41 lines
1.1 KiB
TypeScript
Raw 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 react from '@vitejs/plugin-react'
import path from 'path'
export default defineConfig({
plugins: [react()],
optimizeDeps: {
include: ['lucide-react'],
},
server: {
proxy: {
'/api': {
target: 'http://localhost:3001',
changeOrigin: true,
configure: (proxy) => {
proxy.on('error', () => {}) // 后端未启动时静默失败
},
},
'/ws': {
target: 'ws://localhost:3001',
ws: true,
changeOrigin: true,
configure: (proxy) => {
proxy.on('error', () => {}) // 后端未启动时静默失败
// 抑制关标签/刷新时代理底层 socket 的 ECONNRESET避免刷屏
proxy.on('proxyReqWs', (proxyReq, req, socket, head) => {
socket?.on?.('error', () => {})
const out = (proxyReq as { socket?: { on?: (e: string, fn: () => void) => void } })?.socket
out?.on?.('error', () => {})
})
},
},
},
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
})