|
|
@@ -40,5 +40,21 @@ console.log(
|
|
|
`[build-with-env] ${envFile} → NEXT_PUBLIC_APP_ENV=${env.NEXT_PUBLIC_APP_ENV}, API_PROXY_TARGET=${env.API_PROXY_TARGET}`,
|
|
|
);
|
|
|
|
|
|
-const r = spawnSync("next", ["build"], { cwd: root, env, stdio: "inherit" });
|
|
|
+const nextCli = resolve(root, "node_modules/next/dist/bin/next");
|
|
|
+if (!existsSync(nextCli)) {
|
|
|
+ console.error("[build-with-env] 未找到 next,请先在项目目录执行 npm install");
|
|
|
+ process.exit(1);
|
|
|
+}
|
|
|
+
|
|
|
+const r = spawnSync(process.execPath, [nextCli, "build"], {
|
|
|
+ cwd: root,
|
|
|
+ env,
|
|
|
+ stdio: "inherit",
|
|
|
+});
|
|
|
+
|
|
|
+if (r.error) {
|
|
|
+ console.error("[build-with-env] 启动 next build 失败:", r.error.message);
|
|
|
+ process.exit(1);
|
|
|
+}
|
|
|
+
|
|
|
process.exit(r.status ?? 1);
|