-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.mjs
48 lines (41 loc) · 1.01 KB
/
build.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
import esbuild from "esbuild"
import path from "path";
import { fileURLToPath } from 'url';
import * as fs from "node:fs"
fs.rmSync("dist", { recursive: true, force: true })
fs.mkdirSync("dist")
fs.writeFileSync("dist/package.json", JSON.stringify({ main: "main.js" }))
fs.cpSync("src/index.html", "dist/index.html")
function build(opts) {
esbuild.build(opts).then((result) => {
if (result.errors.length > 0) {
console.error(result.errors);
}
if (result.warnings.length > 0) {
console.error(result.warnings);
}
});
}
const outdir = path.join(path.dirname(fileURLToPath(import.meta.url)), 'dist');
build({
entryPoints: ['src/main.mjs'],
bundle: true,
sourcemap: false,
platform: 'node',
target: 'node16.15',
outdir: 'dist',
external: ['electron'],
})
build({
entryPoints: ['src/preload.mjs'],
bundle: true,
sourcemap: false,
outdir: 'dist',
external: ['electron'],
})
build({
entryPoints: ['src/renderer.mjs'],
bundle: true,
sourcemap: false,
outdir: 'dist',
})