/** @type {import('next').NextConfig} */ const nextConfig = { // 图片优化配置 images: { // 启用图片优化(生产环境) unoptimized: process.env.NODE_ENV === 'development', // 允许的图片域名 remotePatterns: [ { protocol: 'https', hostname: '**', }, ], // 图片格式优化 formats: ['image/avif', 'image/webp'], // 设备尺寸断点 deviceSizes: [640, 750, 828, 1080, 1200, 1920], // 图片尺寸断点 imageSizes: [16, 32, 48, 64, 96, 128, 256], }, // 显式设置为根路径 '/',防止自动推断错误或代理环境下的相对路径解析问题 assetPrefix: '/', // 编译优化 compiler: { // 移除 console.log(生产环境) removeConsole: process.env.NODE_ENV === 'production' ? { exclude: ['error', 'warn'], } : false, }, // 实验性功能 experimental: { // 优化包导入 optimizePackageImports: [ 'lucide-react', '@radix-ui/react-icons', 'date-fns', 'd3', 'echarts', 'recharts', ], }, // 生产环境优化 poweredByHeader: false, // 压缩 compress: true, // 生成静态页面时的超时设置 staticPageGenerationTimeout: 120, } export default nextConfig