You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.5 KiB
55 lines
1.5 KiB
/** @type {import('next').NextConfig} */
|
|
const nextConfig = {
|
|
reactStrictMode: true,
|
|
images: {
|
|
// 启用图片优化
|
|
formats: ['image/avif', 'image/webp'],
|
|
// 图片质量
|
|
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
|
|
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
|
|
// 允许的远程图片域名(如果需要)
|
|
remotePatterns: [],
|
|
// 最小化图片优化延迟
|
|
minimumCacheTTL: 60,
|
|
// 启用图片占位符
|
|
dangerouslyAllowSVG: true,
|
|
contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;",
|
|
},
|
|
// 启用压缩
|
|
compress: true,
|
|
// 启用 SWC 压缩
|
|
swcMinify: true,
|
|
// 优化输出
|
|
output: 'standalone',
|
|
// 实验性功能
|
|
experimental: {
|
|
// 优化包大小(如果使用的包支持)
|
|
// optimizePackageImports: ['@headlessui/react', 'lucide-react'],
|
|
},
|
|
// 开发模式优化
|
|
...(process.env.NODE_ENV === 'development' && {
|
|
// 减少开发模式编译时间
|
|
webpack: (config, { dev, isServer }) => {
|
|
if (dev && !isServer) {
|
|
// 优化开发模式下的模块解析
|
|
config.resolve.alias = {
|
|
...config.resolve.alias,
|
|
};
|
|
// 减少开发模式下的检查
|
|
config.optimization = {
|
|
...config.optimization,
|
|
removeAvailableModules: false,
|
|
removeEmptyChunks: false,
|
|
splitChunks: false,
|
|
};
|
|
}
|
|
return config;
|
|
},
|
|
}),
|
|
// 性能优化
|
|
poweredByHeader: false,
|
|
};
|
|
|
|
export default nextConfig;
|
|
|
|
|
|
|