Files

20 lines
866 B
JavaScript

import { cp, mkdir } from "node:fs/promises";
import path from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
const projectRoot = path.resolve(fileURLToPath(new URL("../", import.meta.url)));
const standaloneRoot = path.join(projectRoot, ".next", "standalone");
await mkdir(path.join(standaloneRoot, ".next", "static"), { recursive: true });
await cp(path.join(projectRoot, ".next", "static"), path.join(standaloneRoot, ".next", "static"), { recursive: true, force: true });
await mkdir(path.join(standaloneRoot, "public"), { recursive: true });
try {
await cp(path.join(projectRoot, "public"), path.join(standaloneRoot, "public"), { recursive: true, force: true });
} catch (error) {
if (error?.code !== "ENOENT") throw error;
}
process.chdir(standaloneRoot);
await import(pathToFileURL(path.join(standaloneRoot, "server.js")).href);