-
Notifications
You must be signed in to change notification settings - Fork 16
/
esbuilder.js
54 lines (49 loc) · 1.35 KB
/
esbuilder.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
// crankshaft's build script. uses esbuild, which is a fast js build tool written in go.
const esbuild = require('esbuild');
const args = process.argv.filter(a => a.startsWith("--"))
const building = args.includes("--build")
const watching = args.includes("--watch")
console.log("building(minifying):", building, "watching:", watching)
const buildLogger = {
name: 'build-logger',
setup(build) {
build.onEnd(result => console.log(`build completed with ${result.errors.length} errors`))
},
}
const buildOptions = {
// keep this manually in-sync!
entryPoints: [
'src/main.ts',
'src/menu.ts',
'src/preload.ts',
'src/requesthandler.ts',
'src/settingsui.ts',
'src/switches.ts',
'src/userscripts.ts',
'src/matchmaker.ts',
'src/utils_node.ts',
'src/utils.ts',
'src/userscriptvalidators.ts',
'src/splashscreen.ts'
],
bundle: false,
minify: building,
sourcemap: false,
format: 'cjs',
platform: 'node',
target: "es2020", // electron 10.4.7 => chromium 85 => released in 2020
banner: {
js: "\"use strict\";"
},
outdir: 'app',
tsconfig: 'tsconfig.json'
}
async function watch(extraOptions) {
const ctx = await esbuild.context(Object.assign(buildOptions, extraOptions))
await ctx.watch()
}
if (watching) {
watch({ plugins: [ buildLogger ] });
} else {
esbuild.buildSync(buildOptions)
}