import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  // Bundle optimization
  experimental: {
    // Optimize package imports for faster builds and smaller bundles
    optimizePackageImports: [
      "lucide-react",
      "@radix-ui/react-dialog",
      "@radix-ui/react-dropdown-menu",
      "@radix-ui/react-select",
    ],
  },
  
  // Webpack optimization
  webpack: (config, { isServer }) => {
    // Split chunks for better caching
    if (!isServer) {
      config.optimization = {
        ...config.optimization,
        splitChunks: {
          chunks: "all",
          cacheGroups: {
            // Vendor chunk for node_modules
            vendor: {
              name: "vendor",
              test: /[\\/]node_modules[\\/]/,
              priority: 10,
              reuseExistingChunk: true,
            },
            // DND kit chunk - heavy library
            dnd: {
              name: "dnd",
              test: /[\\/]node_modules[\\/]@dnd-kit[\\/]/,
              priority: 20,
              reuseExistingChunk: true,
            },
            // Radix UI chunk
            radix: {
              name: "radix",
              test: /[\\/]node_modules[\\/]@radix-ui[\\/]/,
              priority: 15,
              reuseExistingChunk: true,
            },
          },
        },
      };
    }
    return config;
  },
  
  // Image optimization
  images: {
    remotePatterns: [],
  },
  
  // Compression
  compress: true,
  
  // Power optimization - reduce CPU usage
  poweredByHeader: false,
  
  // Trailing slashes for SEO
  trailingSlash: false,
};

export default nextConfig;
