Files
draw/vite.config.ts
2025-09-18 23:34:55 +08:00

71 lines
1.7 KiB
TypeScript

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tsconfigPaths from "vite-tsconfig-paths";
import { traeBadgePlugin } from 'vite-plugin-trae-solo-badge';
// https://vite.dev/config/
export default defineConfig({
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);
});
}
}
}
},
plugins: [
react({
babel: {
plugins: [
'react-dev-locator',
],
},
}),
traeBadgePlugin({
variant: 'dark',
position: 'bottom-right',
prodOnly: true,
clickable: true,
clickUrl: 'https://www.trae.ai/solo?showJoin=1',
autoTheme: true,
autoThemeTarget: '#root'
}),
tsconfigPaths()
],
})