-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
42 lines (35 loc) · 893 Bytes
/
build.js
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
// @ts-check
import { context } from "esbuild";
import dotenv from "dotenv";
dotenv.config({ path: ".dev.vars" });
const isDev = process.env["NODE_ENV"] === "development";
/** @type {import("esbuild").BuildOptions} */
const baseOptions = {
bundle: true,
minify: !isDev,
sourcemap: isDev,
target: "esnext",
legalComments: "none",
logLevel: "info",
color: true,
tsconfig: "tsconfig.json",
sourcesContent: false,
allowOverwrite: true,
format: "esm"
};
const ctx1 = await context({
...baseOptions,
entryPoints: ["src/server.ts"],
outfile: "dist/server.js",
platform: "browser",
external: ["__STATIC_CONTENT_MANIFEST"]
});
const ctx2 = await context({
...baseOptions,
entryPoints: ["src/tools/register.ts"],
outfile: "dist/register.js",
platform: "node",
packages: "external"
});
await Promise.all([ctx1.rebuild(), ctx2.rebuild()]);
process.exit(0);