-
Notifications
You must be signed in to change notification settings - Fork 2
/
esbuild-test.mjs
73 lines (67 loc) · 2.1 KB
/
esbuild-test.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
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
#!/usr/bin/env node
import process from "process";
import * as esbuild from "esbuild";
// Running the build without watching
async function main() {
var browser = build("./src/mainBrowser.ts","out/src/mainBrowser.js","browser");
var node = build("./src/mainNode.ts","out/src/mainNode.js", "node");
var infoView = viewBuild("./views/goals/index.tsx");
var logView = viewBuild("./views/logbook/index.tsx");
var executeView = viewBuild("./views/execute/index.tsx");
var helpView = viewBuild("./views/help/index.tsx");
var searchView = viewBuild("./views/search/index.tsx");
var expandDefinitionView = viewBuild("./views/expandDefinition/index.tsx");
var symbolsView = viewBuild("./views/symbols/index.tsx");
var tacticView = viewBuild("./views/tactics/index.tsx");
const fontLoader = "copy";
var editor = esbuild.build({
entryPoints: ["./editor/src/index.ts"],
bundle: true,
outdir: "./editor_output",
platform: "browser",
loader: {
".woff": fontLoader,
".woff2": fontLoader,
".ttf": fontLoader,
},
}).then(() => {
console.log("Build finished for ./editor/src/index.ts");
}).catch(() => {
process.exit(1);
});
await Promise.all([node, browser, editor, infoView, logView, executeView, helpView, searchView, expandDefinitionView, symbolsView]);
}
async function build(input, output, platform) {
return esbuild
.build({
entryPoints: [input],
bundle: true,
format: "cjs",
platform: platform,
external: ["vscode"],
outfile: output,
loader: {
".html": "text",
}
})
.then(() => {
console.log("Build finished for " + input);
})
.catch(() => process.exit(1));
}
// Build of the VS Code view, for modern Chrome (webview)
function viewBuild(file) {
return esbuild
.build({
entryPoints: [file],
bundle: true,
platform: "browser",
outdir: "out",
outbase: ".",
})
.then(() => {
console.log(`Build finished for ${file}`);
})
.catch(() => process.exit(1));
}
main();