import { defineConfig } from "vite";
import tailwindcss from "@tailwindcss/vite";

export default defineConfig({
  plugins: [tailwindcss()],
  esbuild: {
    jsx: "automatic",
    jsxImportSource: "react",
  },
  build: {
    // Generate source maps for production debugging
    sourcemap: true,
    // Optimize chunk splitting for better caching
    rollupOptions: {
      output: {
        manualChunks: {
          // Bundle React separately (more stable across updates)
          "react-vendor": ["react", "react-dom"],
        },
      },
    },
    // Chunk size warning limit (in kB)
    chunkSizeWarningLimit: 500,
  },
  // Optimize dependency pre-bundling
  optimizeDeps: {
    include: ["react", "react-dom"],
  },
});
