Files
gitlab-instance-0a899031_di…/next.config.ts
2026-03-23 22:59:42 -05:00

42 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { NextConfig } from "next";
/** 由 scripts/build-safe.cjs 设置;在 VPS 上也可手动 export 后执行 pnpm build */
const lowMemBuild = process.env.NEXT_BUILD_LOW_MEM === "1";
const nextConfig: NextConfig = {
experimental: {
serverActions: { bodySizeLimit: "25mb" },
...(lowMemBuild
? {
// 限制并行与预渲染并发降低峰值内存Next 16 默认 Turbopack 构建)
cpus: 1,
turbopackMemoryLimit: 1536 * 1024 * 1024,
staticGenerationMaxConcurrency: 1,
webpackMemoryOptimizations: true,
parallelServerCompiles: false,
parallelServerBuildTraces: false,
}
: {}),
},
async headers() {
const noCacheHeaders = [
{
key: "Cache-Control",
value: "no-store, no-cache, must-revalidate, proxy-revalidate",
},
{ key: "Pragma", value: "no-cache" },
{ key: "Expires", value: "0" },
];
return [
{ source: "/", headers: noCacheHeaders },
{
// 排除 /_next/ 静态资源(含 hash 可长期缓存),其余页面禁用缓存
source: "/:path((?!_next).*)",
headers: noCacheHeaders,
},
];
},
};
export default nextConfig;