import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

export default defineConfig({
  plugins: [react()],
  server: {
    port: 3001,
    proxy: {
      '/api': {
        target: 'http://localhost:3000',
        changeOrigin: true,
      },
    },
  },
  build: {
    rollupOptions: {
      output: {
        manualChunks: {
          // Core React vendor chunk
          'vendor-react': ['react', 'react-dom', 'react-router-dom'],
          // 3D visualization libraries (lazy loaded, kept together for caching)
          'vendor-three': ['three'],
          'vendor-force-graph': ['react-force-graph-3d'],
          // Utilities
          'vendor-utils': ['@tanstack/react-virtual', 'date-fns', 'zustand'],
        },
      },
    },
    // 3D visualization libraries (Three.js, force-graph) are inherently large (~800KB each)
    // These are lazy-loaded and cached separately, so we increase the limit
    chunkSizeWarningLimit: 800,
  },
});
