forked from yy4382/read-aloud
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
55 lines (51 loc) · 1012 Bytes
/
build.js
File metadata and controls
55 lines (51 loc) · 1012 Bytes
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// @ts-check
import * as esbuild from "esbuild";
import { parseArgs } from "node:util";
const args = parseArgs({
options: {
target: {
type: "string",
},
debug: {
type: "boolean",
default: false,
},
},
allowPositionals: false,
strict: true,
});
/**
* @type {Record<string, import("esbuild").BuildOptions>}
*/
const TARGETS = {
workerd: {
entryPoints: ["src/index.ts"],
outdir: "dist-prebuild",
platform: "browser",
external: ["node:*"],
},
node: {
entryPoints: ["entries/node.ts"],
outdir: "dist-node",
platform: "node",
packages: "external",
},
vercel: {
entryPoints: ["src/index.ts"],
outdir: "dist-prebuild",
platform: "node",
packages: "external",
},
};
const target = args.values.target;
if (!target) {
throw new Error("target is required");
}
const targetConfig = TARGETS[target];
// // build server
await esbuild.build({
bundle: true,
format: "esm",
sourcemap: true,
...targetConfig,
});