| import os from "node:os"; | |
| import path from "node:path"; | |
| import { promises as fs } from "node:fs"; | |
| import { build } from "esbuild"; | |
| const outputDir = process.env.BUILD_OUT_DIR || path.join(os.tmpdir(), "oapix-build"); | |
| await fs.rm(outputDir, { force: true, recursive: true }); | |
| await fs.mkdir(outputDir, { recursive: true }); | |
| await build({ | |
| entryPoints: ["src/server.js"], | |
| outfile: path.join(outputDir, "server.js"), | |
| bundle: true, | |
| format: "esm", | |
| platform: "node", | |
| sourcemap: true, | |
| external: ["express", "dotenv", "ffmpeg-static"] | |
| }); | |
| await fs.copyFile("package.json", path.join(outputDir, "package.json")); | |
| await fs.copyFile("package-lock.json", path.join(outputDir, "package-lock.json")).catch(() => {}); | |
| await fs.copyFile(".env.example", path.join(outputDir, ".env.example")); | |
| await fs.cp("public", path.join(outputDir, "public"), { recursive: true }); | |
| console.log(outputDir); | |