Files
draw/vite.config.ts
2025-09-19 00:40:32 +08:00

53 lines
1.4 KiB
TypeScript

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tsconfigPaths from "vite-tsconfig-paths";
// https://vite.dev/config/
export default defineConfig({
plugins: [react(), tsconfigPaths()],
build: {
sourcemap: 'hidden',
// 代码分割优化
rollupOptions: {
output: {
manualChunks: {
vendor: ['react', 'react-dom', 'react-router-dom'],
ui: ['lucide-react'],
utils: ['zustand', 'socket.io-client']
}
}
},
// 压缩优化
minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true
}
},
// 构建性能优化
chunkSizeWarningLimit: 1000
},
server: {
proxy: {
'/api': {
target: 'http://127.0.0.1:3001',
changeOrigin: true,
secure: false,
configure: (proxy) => {
proxy.on('error', (err) => {
console.log('proxy error', err);
});
proxy.on('proxyReq', (proxyReq, req) => {
console.log('Sending Request to the Target:', req.method, req.url);
});
proxy.on('proxyRes', (proxyRes, req) => {
console.log('Received Response from the Target:', proxyRes.statusCode, req.url);
});
}
}
},
allowedHosts: ['draw.xi.plus', 'draw.ngx.center']
},
})