This commit is contained in:
parent
db4b99aee3
commit
1dee8b528f
30 changed files with 3491 additions and 2444 deletions
|
|
@ -3,8 +3,11 @@ import { createServer } from "node:http";
|
|||
import { extname, join, relative, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const root = resolve(fileURLToPath(new URL(".", import.meta.url)), "website");
|
||||
const publicRoot = join(root, "public");
|
||||
const projectRoot = resolve(fileURLToPath(new URL(".", import.meta.url)));
|
||||
const websiteRoot = join(projectRoot, "website");
|
||||
const distRoot = join(websiteRoot, "dist");
|
||||
const root = existsSync(distRoot) ? distRoot : websiteRoot;
|
||||
const publicRoot = existsSync(distRoot) ? distRoot : join(websiteRoot, "public");
|
||||
|
||||
function loadEnvFile(file = ".env") {
|
||||
if (!existsSync(file)) return;
|
||||
|
|
@ -63,7 +66,7 @@ function resolvePath(url) {
|
|||
const publicCandidate = fileIfReadable(resolve(publicRoot, `.${requested}`));
|
||||
if (publicCandidate && isInsideRoot(publicRoot, publicCandidate)) return publicCandidate;
|
||||
|
||||
return join(publicRoot, "index.html");
|
||||
return join(root, "index.html");
|
||||
}
|
||||
|
||||
const server = createServer((req, res) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue