-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.js
More file actions
44 lines (39 loc) · 1.18 KB
/
esbuild.js
File metadata and controls
44 lines (39 loc) · 1.18 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
const esbuild = require("esbuild");
const production = process.argv.includes("--production");
const watch = process.argv.includes("--watch");
async function main() {
// Extension host bundle (Node, CJS)
const extCtx = await esbuild.context({
entryPoints: ["src/extension.ts"],
bundle: true,
outfile: "dist/extension.js",
external: ["vscode"],
format: "cjs",
platform: "node",
sourcemap: !production,
minify: production,
});
// Lineage webview bundle (browser, IIFE)
const lineageCtx = await esbuild.context({
entryPoints: ["src/features/lineage/webview/App.tsx"],
bundle: true,
outfile: "dist/lineage.js",
format: "iife",
platform: "browser",
sourcemap: !production,
minify: production,
jsx: "automatic",
loader: { ".ttf": "file" },
define: {
"process.env.NODE_ENV": production ? '"production"' : '"development"',
},
});
if (watch) {
await Promise.all([extCtx.watch(), lineageCtx.watch()]);
console.log("Watching...");
} else {
await Promise.all([extCtx.rebuild(), lineageCtx.rebuild()]);
await Promise.all([extCtx.dispose(), lineageCtx.dispose()]);
}
}
main().catch(() => process.exit(1));