-
Notifications
You must be signed in to change notification settings - Fork 116
/
build.mjs
40 lines (38 loc) · 850 Bytes
/
build.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
import esbuild from "esbuild";
const production = process.argv[2] === "--production";
const watch = process.argv[2] === "--watch";
const context = await esbuild
.context({
entryPoints: ["./src/extension.ts"],
bundle: true,
outdir: "dist",
external: ["vscode"],
format: "cjs",
sourcemap: !production,
minify: production,
platform: "node",
target: "ES2022",
plugins: [
{
name: "watch",
setup(build) {
build.onEnd(() => {
if (watch) console.log("build finished");
});
build.onStart(() => {
if (watch) console.log("building...");
});
},
},
],
})
.catch((e) => {
console.error(e);
process.exit(1);
});
if (watch) {
await context.watch();
} else {
context.rebuild();
context.dispose();
}