-
Notifications
You must be signed in to change notification settings - Fork 149
Expand file tree
/
Copy pathbuild.mjs
More file actions
35 lines (30 loc) · 810 Bytes
/
build.mjs
File metadata and controls
35 lines (30 loc) · 810 Bytes
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
/**
* 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 = [
"internal/home.html",
"internal/blank.html",
"internal/viewsource.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;
}
}