-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.js
More file actions
52 lines (46 loc) · 1.3 KB
/
Copy pathesbuild.js
File metadata and controls
52 lines (46 loc) · 1.3 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
const esbuild = require("esbuild");
const watch = process.argv.includes("--watch");
const production = process.argv.includes("--production");
/** @type {import('esbuild').BuildOptions} */
const extensionConfig = {
entryPoints: ["src/extension.ts"],
bundle: true,
outfile: "dist/extension.js",
platform: "node",
format: "cjs",
target: "node18",
external: ["vscode"],
sourcemap: !production,
minify: production,
};
/** @type {import('esbuild').BuildOptions} */
const webviewConfig = {
entryPoints: ["src/webview/main.tsx"],
bundle: true,
outfile: "dist/webview.js",
platform: "browser",
format: "iife",
target: "es2022",
jsx: "automatic",
sourcemap: !production,
minify: production,
define: {
"process.env.NODE_ENV": production ? '"production"' : '"development"',
},
};
async function main() {
const ctxExt = await esbuild.context(extensionConfig);
const ctxWeb = await esbuild.context(webviewConfig);
if (watch) {
await Promise.all([ctxExt.watch(), ctxWeb.watch()]);
console.log("[esbuild] watching for changes...");
} else {
await Promise.all([ctxExt.rebuild(), ctxWeb.rebuild()]);
await Promise.all([ctxExt.dispose(), ctxWeb.dispose()]);
console.log("[esbuild] build complete");
}
}
main().catch((err) => {
console.error(err);
process.exit(1);
});