-
Notifications
You must be signed in to change notification settings - Fork 3
/
esbuild.mjs
48 lines (44 loc) · 1.17 KB
/
esbuild.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
import { build, context } from "esbuild";
import glob from "glob";
const minify = process.argv.includes("--minify");
const watch = process.argv.includes("--watch");
/** @type {import('esbuild').BuildOptions} */
const options = {
entryPoints: ["src/extension.ts", "src/test/runTest.ts", ...glob.sync("src/test/suite/*.ts")],
bundle: true,
minify: minify,
sourcemap: true,
outdir: "out",
external: ["mocha", "vscode"],
format: "cjs",
platform: "node",
};
/** @type {import('esbuild').BuildOptions} */
const watchOptions = {
...options,
plugins: [
{
name: "watch",
setup(build) {
build.onEnd((result) => {
console.log("[watch] build started");
if (result.errors.length !== 0) {
result.errors.forEach((error) =>
console.error(
`> ${error.location.file}:${error.location.line}:${error.location.column}: error: ${error.text}`,
),
);
} else {
console.log("[watch] build finished");
}
});
},
},
],
};
if (watch) {
const watchContext = await context(watchOptions);
watchContext.watch();
} else {
build(options);
}