2025-11-12 08:17:28 -08:00
|
|
|
import { defineConfig } from 'vite'
|
|
|
|
|
import react from '@vitejs/plugin-react'
|
|
|
|
|
import { resolve } from 'path'
|
|
|
|
|
|
|
|
|
|
// Optimized Vite Configuration
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
plugins: [react()],
|
|
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
'@': resolve(__dirname, './src'),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
server: {
|
|
|
|
|
port: 3000,
|
|
|
|
|
open: true,
|
|
|
|
|
},
|
|
|
|
|
build: {
|
|
|
|
|
outDir: 'dist',
|
|
|
|
|
sourcemap: true,
|
|
|
|
|
rollupOptions: {
|
|
|
|
|
output: {
|
|
|
|
|
manualChunks: {
|
|
|
|
|
// Core React libraries
|
|
|
|
|
vendor: ['react', 'react-dom'],
|
|
|
|
|
|
|
|
|
|
// UI and animations
|
|
|
|
|
ui: ['framer-motion', 'lucide-react'],
|
|
|
|
|
|
|
|
|
|
// AI and ML libraries (largest chunk)
|
|
|
|
|
ai: ['@tensorflow/tfjs', 'natural', 'ml-matrix', 'compromise'],
|
|
|
|
|
|
|
|
|
|
// Real-time and networking
|
|
|
|
|
realtime: ['socket.io-client', 'ws', 'ioredis', 'redis'],
|
|
|
|
|
|
|
|
|
|
// Queue management
|
|
|
|
|
queue: ['bull', 'uuid'],
|
|
|
|
|
|
|
|
|
|
// Date utilities
|
|
|
|
|
utils: ['date-fns']
|
|
|
|
|
},
|
|
|
|
|
// Optimize chunk sizes
|
|
|
|
|
chunkFileNames: (chunkInfo) => {
|
|
|
|
|
const facadeModuleId = chunkInfo.facadeModuleId
|
|
|
|
|
? chunkInfo.facadeModuleId.split('/').pop()
|
|
|
|
|
: 'chunk'
|
|
|
|
|
return `js/${facadeModuleId}-[hash].js`
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
// Enable compression
|
|
|
|
|
minify: 'terser',
|
|
|
|
|
terserOptions: {
|
|
|
|
|
compress: {
|
|
|
|
|
drop_console: true,
|
|
|
|
|
drop_debugger: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
// Optimize chunks
|
|
|
|
|
chunkSizeWarningLimit: 500,
|
|
|
|
|
},
|
2025-10-05 06:34:26 -07:00
|
|
|
})
|