-
Notifications
You must be signed in to change notification settings - Fork 17
/
build.js
70 lines (62 loc) · 1.58 KB
/
build.js
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
const { build } = require("esbuild");
const path = require("path");
const globalExternals = [
"path",
"fs",
"child_process",
"register-url-win64-bin-uac",
"register-url-win64-bin",
];
const codeSplitFiles = [
"src/confirmPrompt",
"src/Search",
"src/registerProtocol",
];
const PKG_DEFINES = {
SEARCH_PATH: "'src/Search'",
REGISTER_PROTOCOL_PATH: "'src/registerProtocol'",
CONFIRM_PROMPT_PATH: "'src/confirmPrompt'",
};
const REGULAR_DEFINES = {
SEARCH_PATH: "_SEARCH_PATH",
REGISTER_PROTOCOL_PATH: "_REGISTER_PROTOCOL_PATH",
CONFIRM_PROMPT_PATH: "_CONFIRM_PROMPT_PATH",
};
const minify = true;
async function run() {
for (let file of codeSplitFiles) {
await build({
bundle: true,
target: ["node12"],
entryPoints: [file],
outfile: "./bin/" + path.basename(file) + ".js",
platform: "node",
sourcemap: "external",
external: [...globalExternals],
minify,
}).then((a) => console.log("Built.", a.outputFiles));
}
await build({
bundle: true,
target: ["node12"],
entryPoints: ["./src/index.ts"],
outfile: "./bin/git-peek",
platform: "node",
sourcemap: "external",
external: [...globalExternals, ...codeSplitFiles],
define: REGULAR_DEFINES,
minify,
}).then((a) => console.log("Built.", a.outputFiles));
}
build({
bundle: true,
target: ["node12"],
entryPoints: ["./src/index.ts"],
outfile: "./pkgbin/git-peek",
platform: "node",
sourcemap: "external",
external: [...globalExternals],
define: PKG_DEFINES,
minify,
}).then((a) => console.log("Built.", a.outputFiles));
run();