-
Notifications
You must be signed in to change notification settings - Fork 5
/
esbuild.config.mjs
55 lines (48 loc) · 1.36 KB
/
esbuild.config.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
44
45
46
47
48
49
50
51
52
53
54
55
import { exec } from "child_process";
import { performance } from "perf_hooks";
import esbuild from "esbuild";
const devMode = process.env.NODE_ENV === "development";
async function execCmd(command) {
return new Promise((resolve, reject) => {
exec(command, (error, stdout, stderr) => {
if (error) {
reject([error, stdout, stderr]);
return;
}
resolve(stdout);
});
});
}
let last = performance.now();
await execCmd("npx tsc --noEmit").then(
(stdout) => {
if (stdout.length > 0) {
console.log(stdout);
}
console.log("tsc done in", (performance.now() - last).toFixed(2), "ms.");
},
([error, stdout, stderr]) => {
console.error(error.message);
if (stderr.length > 0) {
console.error(stderr);
}
if (stdout.length > 0) {
console.error(stdout);
}
process.exit(1);
}
);
last = performance.now();
await esbuild.build({
entryPoints: ["src/main.ts"],
outfile: "dist/title-bar-replacer.js",
bundle: true,
platform: "node",
target: ["node14"],
sourcemap: true,
external: ["atom", "electron"],
minify: devMode ? false : true,
}).catch(_reason => {
process.exit(1);
});
console.log("Esbuild done in", (performance.now() - last).toFixed(2), "ms.");