vblog
Script
99
1
2
3
4
5
6
7
8
9
10
11
/** Import a file relative to the root of the project */
export async function importFile(path: string) {
const url = new URL(path, import.meta.url);
console.log(url);
const res = await fetch(url, { redirect: "follow" });
if (!res.ok) return null;
return await res.text();
}
// consider replacing with: https://www.val.town/v/maxm/importProjectFile
// REF
// const resp = await fetch(import.meta.resolve("./foo.css"), {redirect: "follow"});