forked from jscoq/jscoq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesbuild-cli.mjs
43 lines (39 loc) · 1.17 KB
/
esbuild-cli.mjs
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
#!/usr/bin/env node
import process from "process";
import * as esbuild from "esbuild";
let watchConfig = (entry) => {
return {
onRebuild(error, result) {
console.log(`[watch] build started (rebuild for ${entry})`);
if (error) {
error.errors.forEach((error) =>
console.error(
`> ${error.location.file}:${error.location.line}:${error.location.column}: error: ${error.text}`
)
);
} else console.log(`[watch] build finished (rebuild for ${entry}`);
},
};
};
let watch = process.argv.includes("--watch") ? watchConfig : (entry) => false;
let minify = process.argv.includes("--minify");
let disable_sourcemap = process.argv.includes("--sourcemap=no");
let sourcemap = disable_sourcemap ? null : { sourcemap: true };
// Node build
var cliEntry = "./frontend/cli/cli.ts";
var nodecli = esbuild
.build({
entryPoints: [cliEntry],
bundle: true,
platform: "node",
format: "cjs",
outfile: "dist-cli/cli.cjs",
...sourcemap,
minify,
// watch: watch(cliEntry),
})
.then(() => {
console.log(`[watch] build finished for ${cliEntry}`);
})
.catch(() => process.exit(1));
await nodecli;