Files
2026-03-23 22:59:42 -05:00

31 lines
730 B
JavaScript
Raw Permalink 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.
/**
* 低端 VPS / 小内存环境:限制 Node 堆、开启 Next 低内存构建选项。
* 用法pnpm build默认经本脚本
* 可选环境变量:
* NEXT_BUILD_HEAP_MB — Node --max-old-space-size默认 1536
*/
const { spawnSync } = require("child_process");
const path = require("path");
const heapMb = process.env.NEXT_BUILD_HEAP_MB || "1536";
const nextBin = path.join(
path.dirname(require.resolve("next/package.json")),
"dist",
"bin",
"next"
);
const result = spawnSync(
process.execPath,
["--max-old-space-size=" + heapMb, nextBin, "build"],
{
stdio: "inherit",
env: {
...process.env,
NEXT_BUILD_LOW_MEM: "1",
},
}
);
process.exit(result.status ?? 1);