50 lines
2.2 KiB
JavaScript
50 lines
2.2 KiB
JavaScript
const cdnDomain = process.env.CDN_DOMAIN || '';
|
|
|
|
const nextConfig = {
|
|
output: 'standalone',
|
|
// 默认 dist/;可用 NEXT_DIST_DIR 覆盖(CI 分环境输出,或本地需要避开既有构建产物)
|
|
distDir: process.env.NEXT_DIST_DIR || 'dist',
|
|
assetPrefix: cdnDomain || undefined,
|
|
images: {
|
|
// 有意关闭 Next 图片优化:产物经 Nginx 静态托管 + CDN 分发(见 docs/CDN_CONFIGURATION.md、
|
|
// CLAUDE.md「Images are unoptimized (static export limitation)」)。
|
|
// 不要仅因「性能」理由改为 false —— 在无 Node 运行时接管 /_next/image 的部署模式下会导致图片 404。
|
|
unoptimized: true,
|
|
// 注意:unoptimized 为 true 时下面这行不生效,仅在改回 false 后才会参与构建产物生成。
|
|
formats: ['image/avif', 'image/webp'],
|
|
},
|
|
compress: true,
|
|
poweredByHeader: false,
|
|
reactStrictMode: true,
|
|
experimental: {
|
|
optimizePackageImports: ['lucide-react', 'framer-motion'],
|
|
},
|
|
compiler: {
|
|
removeConsole: process.env.NODE_ENV === 'production',
|
|
},
|
|
generateEtags: true,
|
|
httpAgentOptions: {
|
|
keepAlive: true,
|
|
},
|
|
async headers() {
|
|
return [
|
|
{
|
|
source: '/(.*)',
|
|
headers: [
|
|
{ key: 'X-Content-Type-Options', value: 'nosniff' },
|
|
{ key: 'X-Frame-Options', value: 'DENY' },
|
|
{ key: 'X-XSS-Protection', value: '1; mode=block' },
|
|
{ key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },
|
|
{
|
|
key: 'Content-Security-Policy',
|
|
value: "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://www.googletagmanager.com https://ssl.google-analytics.com; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: https://www.google-analytics.com https://ssl.google-analytics.com https://www.googletagmanager.com; font-src 'self'; connect-src 'self' https://www.google-analytics.com https://ssl.google-analytics.com https://www.googletagmanager.com; frame-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self';",
|
|
},
|
|
{ key: 'Permissions-Policy', value: 'camera=(), microphone=(), geolocation=(), interest-cohort=()' },
|
|
],
|
|
},
|
|
];
|
|
},
|
|
};
|
|
|
|
export default nextConfig;
|