-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathoverlay-build.js
More file actions
78 lines (68 loc) · 2.09 KB
/
overlay-build.js
File metadata and controls
78 lines (68 loc) · 2.09 KB
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
74
75
76
77
78
const esbuild = require("esbuild");
const fs = require("fs-extra");
const path = require("path");
const production = process.argv.includes("--production");
async function main() {
// Ensure output directory exists
await fs.ensureDir("./dist/live2d-container");
// Bundle the Electron main process
await esbuild.build({
entryPoints: ["live2d-container/main.js"],
bundle: true,
platform: "node",
target: ["node16"],
minify: production,
sourcemap: !production,
outfile: "dist/live2d-container/main.js",
external: ["electron"],
logLevel: "info"
});
// Bundle the Electron preload script
await esbuild.build({
entryPoints: ["live2d-container/preload.js"],
bundle: true,
platform: "node",
target: ["node16"],
minify: production,
sourcemap: !production,
outfile: "dist/live2d-container/preload.js",
external: ["electron"],
logLevel: "info"
});
// Bundle the Electron renderer process (named index.js)
await esbuild.build({
entryPoints: ["live2d-container/index.js"],
bundle: true,
platform: "browser",
target: ["chrome90"],
minify: production,
sourcemap: !production,
outfile: "dist/live2d-container/index.js",
external: ["electron"],
logLevel: "info"
});
// Copy any HTML files
const htmlFiles = await fs.readdir("live2d-container")
.then(files => files.filter(file => file.endsWith(".html")));
for (const htmlFile of htmlFiles) {
await fs.copy(
path.join("live2d-container", htmlFile),
path.join("dist/live2d-container", htmlFile)
);
}
// Copy all the .css files
const cssFiles = await fs.readdir("live2d-container")
.then(files => files.filter(file => file.endsWith(".css")));
for (const cssFile of cssFiles) {
await fs.copy(
path.join("live2d-container", cssFile),
path.join("dist/live2d-container", cssFile)
);
}
await fs.copy("live2d-container/package.json", "dist/live2d-container/package.json");
console.log("Overlay build complete!");
}
main().catch(error => {
console.error("Build failed:", error);
process.exit(1);
});