181 lines
5.0 KiB
JavaScript
181 lines
5.0 KiB
JavaScript
/** @type {import('next').NextConfig} */
|
|
|
|
// Production-ready Next.js configuration with standalone output
|
|
// This configuration is optimized for Docker deployment with minimal image size
|
|
//
|
|
// Key features:
|
|
// - Standalone output mode (includes only necessary dependencies)
|
|
// - Image optimization with modern formats
|
|
// - Static Site Generation (SSG) for all blog posts
|
|
// - Production-grade caching and performance settings
|
|
//
|
|
// Usage:
|
|
// 1. Copy this file to project root: cp next.config.js.production next.config.js
|
|
// 2. Build application: npm run build
|
|
// 3. The .next/standalone directory will contain everything needed to run the app
|
|
|
|
const nextConfig = {
|
|
// ============================================
|
|
// Standalone Output Mode
|
|
// ============================================
|
|
// This is REQUIRED for Docker deployment
|
|
// Outputs a minimal server with only necessary dependencies
|
|
// Reduces Docker image size from ~1GB to ~150MB
|
|
output: 'standalone',
|
|
|
|
// ============================================
|
|
// Image Optimization
|
|
// ============================================
|
|
images: {
|
|
// Modern image formats (smaller file sizes)
|
|
formats: ['image/avif', 'image/webp'],
|
|
|
|
// Device sizes for responsive images
|
|
// Next.js will generate optimized images for these widths
|
|
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
|
|
|
|
// Image sizes for <Image> component size prop
|
|
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
|
|
|
|
// Disable image optimization during build (optional)
|
|
// Uncomment if build times are too long
|
|
// unoptimized: false,
|
|
|
|
// External image domains (if loading images from CDN)
|
|
// Uncomment and add domains if needed
|
|
// remotePatterns: [
|
|
// {
|
|
// protocol: 'https',
|
|
// hostname: 'cdn.example.com',
|
|
// },
|
|
// ],
|
|
},
|
|
|
|
// ============================================
|
|
// Performance Optimization
|
|
// ============================================
|
|
|
|
// Enable SWC minification (faster than Terser)
|
|
swcMinify: true,
|
|
|
|
// Compress static pages (reduces bandwidth)
|
|
compress: true,
|
|
|
|
// ============================================
|
|
// Production Settings
|
|
// ============================================
|
|
|
|
// Disable X-Powered-By header for security
|
|
poweredByHeader: false,
|
|
|
|
// Generate ETags for caching
|
|
generateEtags: true,
|
|
|
|
// ============================================
|
|
// Static Generation Settings
|
|
// ============================================
|
|
|
|
// Automatically generate static pages at build time
|
|
// This is the default behavior for Next.js App Router
|
|
// All markdown blog posts will be pre-rendered
|
|
|
|
// ============================================
|
|
// TypeScript Settings
|
|
// ============================================
|
|
|
|
// Type checking during build
|
|
// Set to false to skip type checking (not recommended)
|
|
typescript: {
|
|
// ignoreBuildErrors: false,
|
|
},
|
|
|
|
// ============================================
|
|
// ESLint Settings
|
|
// ============================================
|
|
|
|
// ESLint during build
|
|
// Set to false to skip linting (not recommended)
|
|
eslint: {
|
|
// ignoreDuringBuilds: false,
|
|
},
|
|
|
|
// ============================================
|
|
// Experimental Features (Next.js 16)
|
|
// ============================================
|
|
|
|
experimental: {
|
|
// Enable optimistic client cache
|
|
// Improves navigation performance
|
|
staleTimes: {
|
|
dynamic: 30,
|
|
static: 180,
|
|
},
|
|
|
|
// Enable PPR (Partial Prerendering) - Next.js 16 feature
|
|
// Uncomment to enable (currently in beta)
|
|
// ppr: false,
|
|
},
|
|
|
|
// ============================================
|
|
// Headers (Optional)
|
|
// ============================================
|
|
// Custom headers for all routes
|
|
// Note: Caddy/Nginx reverse proxy can also set these headers
|
|
// Uncomment if you want Next.js to handle headers instead
|
|
//
|
|
async headers() {
|
|
return [
|
|
{
|
|
source: '/:path*',
|
|
headers: [
|
|
{
|
|
key: 'X-Content-Type-Options',
|
|
value: 'nosniff',
|
|
},
|
|
{
|
|
key: 'X-Frame-Options',
|
|
value: 'DENY',
|
|
},
|
|
{
|
|
key: 'X-XSS-Protection',
|
|
value: '1; mode=block',
|
|
},
|
|
],
|
|
},
|
|
]
|
|
},
|
|
|
|
// ============================================
|
|
// Redirects (Optional)
|
|
// ============================================
|
|
// Add permanent redirects for old URLs
|
|
// Uncomment and add your redirects
|
|
//
|
|
// async redirects() {
|
|
// return [
|
|
// {
|
|
// source: '/old-blog/:slug',
|
|
// destination: '/blog/:slug',
|
|
// permanent: true,
|
|
// },
|
|
// ]
|
|
// },
|
|
|
|
// ============================================
|
|
// Rewrites (Optional)
|
|
// ============================================
|
|
// Add URL rewrites for API proxying or URL masking
|
|
// Uncomment and add your rewrites
|
|
//
|
|
// async rewrites() {
|
|
// return [
|
|
// {
|
|
// source: '/api/:path*',
|
|
// destination: 'https://api.example.com/:path*',
|
|
// },
|
|
// ]
|
|
// },
|
|
}
|
|
|
|
module.exports = nextConfig
|