forked from w3f/1k-validators-be
-
Notifications
You must be signed in to change notification settings - Fork 0
/
esbuild.js
87 lines (81 loc) · 1.54 KB
/
esbuild.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import esbuild from "esbuild";
const externalPackages = [
"@polkadot/api-augment",
"velocityjs",
"dustjs-linkedin",
"atpl",
"liquor",
"twig",
"eco",
"jazz",
"jqtpl",
"hamljs",
"hamlet",
"whiskers",
"haml-coffee",
"hogan.js",
"templayed",
"underscore",
"walrus",
"mustache",
"just",
"ect",
"mote",
"toffee",
"dot",
"bracket-template",
"ractive",
"htmling",
"babel-core",
"plates",
"vash",
"slm",
"marko",
"teacup/lib/express",
"coffee-script",
"squirrelly",
"twing",
"matris-js-sdk",
"@1kv/telemetry",
"@1kv/gateway",
"@1kv/common",
];
const isProduction = process.argv.includes("--prod");
const buildOptions = {
entryPoints: ["src/index.ts"],
bundle: true,
minify: isProduction,
platform: "node",
target: "node18",
external: externalPackages,
outdir: "build",
// entryNames: "[dir]/[name].mjs",
tsconfig: "tsconfig.json",
splitting: true,
format: "esm",
// outExtension: { ".js": ".mjs" },
sourcemap: !isProduction,
logLevel: "info",
};
if (process.argv.includes("--watch")) {
buildOptions.watch = {
onRebuild(error, result) {
if (error) console.error("watch build failed:", error);
else
console.log(
"watch build succeeded at",
new Date().toLocaleTimeString(),
);
},
};
console.log("watch mode enabled");
}
if (isProduction) {
buildOptions.define = {
"process.env.NODE_ENV": "'production'",
};
}
esbuild.build(buildOptions).catch((error) => {
console.error(error);
process.exit(1);
});