-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ts
46 lines (44 loc) · 1.18 KB
/
build.ts
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
import * as esbuild from "esbuild";
const isWatch = process.argv[2] === "watch";
if (isWatch) {
const ctx = await esbuild.context({
logLevel: "info",
bundle: true,
entryPoints: ["./src/index.ts"],
outdir: "./dist",
outExtension: { ".js": ".mjs" },
platform: "node",
format: "esm",
loader: {
".graphql": "text",
},
banner: {
js: `
const require = (await import("node:module")).createRequire(import.meta.url);
const __filename = (await import("node:url")).fileURLToPath(import.meta.url);
const __dirname = (await import("node:path")).dirname(__filename);
`,
},
});
await ctx.watch();
} else {
await esbuild.build({
logLevel: "info",
bundle: true,
entryPoints: ["./src/index.ts"],
outdir: "./dist",
outExtension: { ".js": ".mjs" },
platform: "node",
format: "esm",
loader: {
".graphql": "text",
},
banner: {
js: `
const require = (await import("node:module")).createRequire(import.meta.url);
const __filename = (await import("node:url")).fileURLToPath(import.meta.url);
const __dirname = (await import("node:path")).dirname(__filename);
`,
},
});
}