forked from matheuslenke/Tonto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
esbuild.js
71 lines (66 loc) · 2.19 KB
/
esbuild.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
71
//@ts-check
const watch = process.argv.includes("--watch");
const minify = process.argv.includes("--minify");
const successExtension = watch
? "Watch build Extension succeeded"
: "Build Extension succeeded";
const successCli = watch ? "Watch build CLI succeeded" : "Build CLI succeeded";
function getTime() {
const date = new Date();
return `[${`${padZeroes(date.getHours())}:${padZeroes(
date.getMinutes()
)}:${padZeroes(date.getSeconds())}`}] `;
}
function padZeroes(i) {
return i.toString().padStart(2, "0");
}
const esbuild = require("esbuild");
/**
* This is the entry point for building the Extension
*/
esbuild
.build({
// Two entry points, one for the extension, one for the language server
entryPoints: ["src/extension.ts", "src/language-server/main.ts"],
outdir: "out",
bundle: true,
external: ["vscode"], // the vscode-module is created on-the-fly and must be excluded.
platform: "node", // VSCode extensions run in a node process
sourcemap: !minify,
watch: watch
? {
onRebuild(error) {
if (error) console.error("Watch build failed");
else console.log(successExtension);
},
}
: false,
minify,
})
.then(() => console.log(`${getTime()}${successExtension}`))
.catch(() => process.exit(1));
/**
* This is the entry point for building the CLI
*/
esbuild
.build({
entryPoints: ["src/cli/index.ts"],
outdir: "out/cli",
bundle: true,
loader: { ".ts": "ts" },
external: ["vscode"], // the vscode-module is created on-the-fly and must be excluded.
platform: "node", // VSCode extensions run in a node process
sourcemap: true,
minifyIdentifiers: false,
watch: watch
? {
onRebuild(error) {
if (error) console.error(`${getTime()}Watch build failed`);
else console.log(`${getTime()}${successCli}`);
},
}
: false,
minify,
})
.then(() => console.log(`${getTime()}${successCli}`))
.catch(() => process.exit(1));