-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-site.mjs
More file actions
39 lines (33 loc) · 1.06 KB
/
Copy pathbuild-site.mjs
File metadata and controls
39 lines (33 loc) · 1.06 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
import { access, cp, mkdir, rm, writeFile } from "node:fs/promises";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
const output = resolve(root, "dist");
const clientOutput = resolve(output, "client");
const staticEntries = [
"index.html",
"app.js",
"tutorial-data.js",
"validation-regexes.js",
"styles.css",
"images",
"vendor",
];
await access(resolve(root, "index.html"));
await rm(output, { recursive: true, force: true });
await mkdir(clientOutput, { recursive: true });
await mkdir(resolve(output, "server"), { recursive: true });
for (const entry of staticEntries) {
await cp(resolve(root, entry), resolve(clientOutput, entry), { recursive: true });
}
await cp(resolve(root, "index.html"), resolve(clientOutput, "404.html"));
await writeFile(
resolve(output, "server", "index.js"),
`export default {
async fetch(request, env) {
return env.ASSETS.fetch(request);
},
};
`,
);
console.log("Built LiquidJava Interactive Tutorial in dist/");