auto-claude: subtask-2-2 - Optimize next.config.ts for performance
This commit is contained in:
+69
-37
@@ -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,56 +30,80 @@ 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 [
|
||||
// Security headers for all routes
|
||||
const securityHeaders = [
|
||||
{
|
||||
source: '/:path*',
|
||||
headers: [
|
||||
{
|
||||
key: 'X-DNS-Prefetch-Control',
|
||||
value: 'on',
|
||||
},
|
||||
{
|
||||
key: 'X-Frame-Options',
|
||||
value: 'SAMEORIGIN',
|
||||
},
|
||||
{
|
||||
key: 'X-Content-Type-Options',
|
||||
value: 'nosniff',
|
||||
},
|
||||
],
|
||||
key: 'X-DNS-Prefetch-Control',
|
||||
value: 'on',
|
||||
},
|
||||
{
|
||||
key: 'X-Frame-Options',
|
||||
value: 'SAMEORIGIN',
|
||||
},
|
||||
{
|
||||
key: 'X-Content-Type-Options',
|
||||
value: 'nosniff',
|
||||
},
|
||||
{
|
||||
key: 'X-XSS-Protection',
|
||||
value: '1; mode=block',
|
||||
},
|
||||
{
|
||||
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: [
|
||||
{
|
||||
key: 'Cache-Control',
|
||||
value: 'public, max-age=31536000, immutable',
|
||||
},
|
||||
],
|
||||
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',
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user