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 = {
|
const nextConfig: NextConfig = {
|
||||||
output: 'standalone',
|
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'],
|
pageExtensions: ['js', 'jsx', 'md', 'mdx', 'ts', 'tsx'],
|
||||||
|
|
||||||
images: {
|
images: {
|
||||||
formats: ['image/avif', 'image/webp'],
|
formats: ['image/avif', 'image/webp'],
|
||||||
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048],
|
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048],
|
||||||
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
|
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
|
||||||
|
// Cache remote images for 30 days
|
||||||
|
minimumCacheTTL: 60 * 60 * 24 * 30,
|
||||||
remotePatterns: [
|
remotePatterns: [
|
||||||
{
|
{
|
||||||
protocol: 'https',
|
protocol: 'https',
|
||||||
@@ -22,56 +30,80 @@ const nextConfig: NextConfig = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
experimental: {
|
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() {
|
async headers() {
|
||||||
return [
|
// Security headers for all routes
|
||||||
|
const securityHeaders = [
|
||||||
{
|
{
|
||||||
source: '/:path*',
|
key: 'X-DNS-Prefetch-Control',
|
||||||
headers: [
|
value: 'on',
|
||||||
{
|
|
||||||
key: 'X-DNS-Prefetch-Control',
|
|
||||||
value: 'on',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'X-Frame-Options',
|
|
||||||
value: 'SAMEORIGIN',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'X-Content-Type-Options',
|
|
||||||
value: 'nosniff',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
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*',
|
source: '/fonts/:path*',
|
||||||
headers: [
|
headers: immutableCacheHeader,
|
||||||
{
|
|
||||||
key: 'Cache-Control',
|
|
||||||
value: 'public, max-age=31536000, immutable',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
source: '/images/:path*',
|
source: '/images/:path*',
|
||||||
headers: [
|
headers: immutableCacheHeader,
|
||||||
{
|
|
||||||
key: 'Cache-Control',
|
|
||||||
value: 'public, max-age=31536000, immutable',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
source: '/_next/static/:path*',
|
source: '/_next/static/:path*',
|
||||||
headers: [
|
headers: immutableCacheHeader,
|
||||||
{
|
|
||||||
key: 'Cache-Control',
|
|
||||||
value: 'public, max-age=31536000, immutable',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
// 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*',
|
source: '/de/:path*',
|
||||||
headers: [
|
headers: [
|
||||||
@@ -102,7 +134,7 @@ const nextConfig: NextConfig = {
|
|||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
|
||||||
// Compiler-Optimierungen
|
// Compiler optimizations
|
||||||
compiler: {
|
compiler: {
|
||||||
removeConsole: process.env.NODE_ENV === 'production',
|
removeConsole: process.env.NODE_ENV === 'production',
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user