From e51d23c5d675627419b235327ee450834b3050d7 Mon Sep 17 00:00:00 2001 From: kleap-admin Date: Fri, 16 Jan 2026 16:33:52 +0000 Subject: [PATCH] Update next.config.mjs --- next.config.mjs | 136 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 next.config.mjs diff --git a/next.config.mjs b/next.config.mjs new file mode 100644 index 0000000..fb0c6c7 --- /dev/null +++ b/next.config.mjs @@ -0,0 +1,136 @@ +import nextMDX from "@next/mdx"; +import path from "path"; + +/** @type {import('next').NextConfig} */ +const nextConfig = { + // Turbopack configuration + turbopack: { + // Configure MDX loader for Turbopack + rules: { + '*.mdx': { + loaders: ['@mdx-js/loader'], + as: '*.js', + }, + }, + }, + + experimental: { + // Optimize bundling + optimizePackageImports: [ + 'lucide-react', + 'react-icons', + '@tabler/icons-react', + 'framer-motion', + 'react-hook-form', + '@radix-ui/react-label', + '@radix-ui/react-slot', + ], + }, + + // Suppress hydration warnings globally + reactStrictMode: false, + + // Image optimization + images: { + remotePatterns: [ + { + protocol: 'https', + hostname: 'i.pravatar.cc', + }, + { + protocol: 'https', + hostname: 'images.unsplash.com', + }, + { + protocol: 'https', + hostname: '*.supabase.co', + }, + { + protocol: 'https', + hostname: 'www.robot-speed.com', + }, + { + protocol: 'https', + hostname: 'robot-speed.com', + }, + ], + formats: ['image/avif', 'image/webp'], + loader: 'default', + dangerouslyAllowSVG: true, + contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;", + }, + + // Page extensions - include .js/.jsx for compatibility + pageExtensions: ["js", "jsx", "ts", "tsx", "mdx"], + + // Performance optimizations + poweredByHeader: false, + compress: true, + + // TypeScript configuration + typescript: { + ignoreBuildErrors: false + }, + + // Compiler optimizations + compiler: { + // Remove console logs in production + removeConsole: process.env.NODE_ENV === 'production', + // Remove data-testid in production + reactRemoveProperties: process.env.NODE_ENV === 'production' ? { properties: ['^data-testid$'] } : false, + }, + + // Module transpilation + transpilePackages: ['geist', 'cobe'], + + // Webpack configuration for aliases and specific replacements + webpack: (config, { webpack }) => { + config.resolve.alias = { + ...config.resolve.alias, + '@': path.resolve('.'), + }; + + const isVercel = process.env.VERCEL === '1' || + process.env.VERCEL === 'true' || + process.env.NEXT_PUBLIC_VERCEL === '1'; + const isProduction = process.env.NODE_ENV === 'production'; + + if (isVercel || isProduction) { + config.plugins.push( + new webpack.NormalModuleReplacementPlugin( + /tailwind-cdn-loader/, + path.resolve('./components/empty-loader.tsx') + ) + ); + } + + return config; + }, + + async headers() { + return [ + { + source: '/:path*', + headers: [ + { + key: 'X-Frame-Options', + value: 'ALLOWALL', + }, + { + key: 'Cache-Control', + value: 'no-store, no-cache, must-revalidate, proxy-revalidate', + }, + ], + }, + ]; + }, +}; + +const withMDX = nextMDX({ + extension: /\.mdx?$/, + options: { + providerImportSource: '@mdx-js/react', + }, +}); + +export default withMDX(nextConfig);