forked from cognetwork-dev/Metallic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.mjs
41 lines (36 loc) · 873 Bytes
/
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
/**
* Creates additional HTML files for react-router-dom to work correctly.
*/
import { copyFile, mkdir } from "node:fs/promises";
const buildURL = new URL("./build/", import.meta.url);
const indexURL = new URL("index.html", buildURL);
/**
* Paths relative to buildURL
*/
const files = [
"settings/appearance.html",
"settings/search.html",
"settings/tab.html",
"settings/ui.html",
"apps.html",
"games.html",
"support.html",
"credits.html",
"privacy.html",
// for static file hosts
"404.html",
];
for (const file of files) {
const output = new URL(file, buildURL);
try {
await mkdir(new URL(".", output), { recursive: true });
} catch (err) {
if (err?.code !== "EEXIST") throw err;
}
try {
await copyFile(indexURL, output);
console.log(output.href);
} catch (err) {
if (err?.code !== "EEXIST") throw err;
}
}