File size: 894 Bytes
e43a4a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2671e04
e43a4a9
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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);