auto-claude: subtask-2-2 - Optimize next.config.ts for performance

This commit is contained in:
2026-01-25 00:16:27 +01:00
parent 1981980a8f
commit a6d0e28990
+55 -23
View File
@@ -7,12 +7,20 @@ const withNextIntl = createNextIntlPlugin('./src/i18n/request.ts');
const nextConfig: NextConfig = {
output: 'standalone',
// Enable React strict mode for better error detection
reactStrictMode: true,
// Remove X-Powered-By header for security
poweredByHeader: false,
pageExtensions: ['js', 'jsx', 'md', 'mdx', 'ts', 'tsx'],
images: {
formats: ['image/avif', 'image/webp'],
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048],
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
// Cache remote images for 30 days
minimumCacheTTL: 60 * 60 * 24 * 30,
remotePatterns: [
{
protocol: 'https',
@@ -22,14 +30,20 @@ const nextConfig: NextConfig = {
},
experimental: {
optimizePackageImports: ['lucide-react', 'framer-motion'],
// Tree-shake large packages for smaller bundles
optimizePackageImports: [
'lucide-react',
'framer-motion',
'@supabase/supabase-js',
'clsx',
'tailwind-merge',
'react-intersection-observer',
],
},
async headers() {
return [
{
source: '/:path*',
headers: [
// Security headers for all routes
const securityHeaders = [
{
key: 'X-DNS-Prefetch-Control',
value: 'on',
@@ -42,36 +56,54 @@ const nextConfig: NextConfig = {
key: 'X-Content-Type-Options',
value: 'nosniff',
},
],
{
key: 'X-XSS-Protection',
value: '1; mode=block',
},
{
source: '/fonts/:path*',
headers: [
key: 'Referrer-Policy',
value: 'strict-origin-when-cross-origin',
},
{
// Enforce HTTPS (1 year, include subdomains, allow preload list)
key: 'Strict-Transport-Security',
value: 'max-age=31536000; includeSubDomains; preload',
},
{
// Restrict browser features for security
key: 'Permissions-Policy',
value: 'camera=(), microphone=(), geolocation=(), interest-cohort=()',
},
];
// Long-term caching for immutable assets
const immutableCacheHeader = [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable',
},
],
];
return [
// Apply security headers to all routes
{
source: '/:path*',
headers: securityHeaders,
},
// Cache static assets aggressively
{
source: '/fonts/:path*',
headers: immutableCacheHeader,
},
{
source: '/images/:path*',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable',
},
],
headers: immutableCacheHeader,
},
{
source: '/_next/static/:path*',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable',
headers: immutableCacheHeader,
},
],
},
// Content-Language Headers für jede Sprache (wichtig für Bing)
// Content-Language headers for SEO (important for Bing and other search engines)
{
source: '/de/:path*',
headers: [
@@ -102,7 +134,7 @@ const nextConfig: NextConfig = {
];
},
// Compiler-Optimierungen
// Compiler optimizations
compiler: {
removeConsole: process.env.NODE_ENV === 'production',
},