31 lines
682 B
TypeScript
31 lines
682 B
TypeScript
import { defineConfig } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
import path from 'path'
|
|
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
server: {
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://localhost:3001',
|
|
changeOrigin: true,
|
|
configure: (proxy) => {
|
|
proxy.on('error', () => {}) // 后端未启动时静默失败
|
|
},
|
|
},
|
|
'/ws': {
|
|
target: 'ws://localhost:3001',
|
|
ws: true,
|
|
configure: (proxy) => {
|
|
proxy.on('error', () => {}) // 后端未启动时静默失败
|
|
},
|
|
},
|
|
},
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src'),
|
|
},
|
|
},
|
|
})
|