app-hopping-lemur-zoom/next.config.mjs

137 lines
3.1 KiB
JavaScript

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);