forked from KxSystems/kx-vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.mjs
More file actions
82 lines (75 loc) · 1.77 KB
/
Copy pathesbuild.mjs
File metadata and controls
82 lines (75 loc) · 1.77 KB
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
import { context, build } from "esbuild";
const minify = process.argv.includes("--minify");
const sourcemap = process.argv.includes("--sourcemap");
const keepNames = process.argv.includes("--keep-names");
const watch = process.argv.includes("--watch");
const baseConfig = {
minify,
sourcemap,
keepNames,
bundle: true,
};
const cssConfig = {
...baseConfig,
entryPoints: [
"./src/webview/styles/style.css",
"./src/webview/styles/light.css",
],
outdir: "./out",
};
const webviewConfig = {
...baseConfig,
entryPoints: ["./src/webview/main.ts"],
outfile: "./out/webview.js",
format: "esm",
target: "es2020",
external: ["vscode"],
};
const serverConfig = {
...baseConfig,
entryPoints: ["./server/src/server.ts"],
outfile: "./out/server.js",
format: "cjs",
platform: "node",
external: ["vscode"],
};
const extensionConfig = {
...baseConfig,
entryPoints: ["./src/extension.ts"],
outfile: "./out/extension.js",
format: "cjs",
platform: "node",
external: ["vscode"],
};
if (watch) {
console.log("esbuild:started");
Promise.all([
context(cssConfig),
context(webviewConfig),
context(serverConfig),
context(extensionConfig),
])
.then((contexts) =>
Promise.all(contexts.map((ctx) => ctx.rebuild())).finally(() =>
Promise.all(contexts.map((ctx) => ctx.watch({ delay: 500 })))
.then(() => console.log("esbuild:watching"))
.catch((error) => {
console.error(error);
process.exit(1);
}),
),
)
.catch((error) => {
console.error(error);
});
} else {
Promise.all([
build(cssConfig),
build(webviewConfig),
build(serverConfig),
build(extensionConfig),
]).catch((error) => {
console.error(error);
process.exit(1);
});
}