fix
This commit is contained in:
parent
466fb90533
commit
fae641a2b3
|
|
@ -26,24 +26,31 @@ export const serveStatic = {
|
||||||
delete cache.static[k];
|
delete cache.static[k];
|
||||||
}
|
}
|
||||||
|
|
||||||
["app/static", "app/web/public"].forEach((base_path) => {
|
watch(dir.data(`static`), async (event, filename) => {
|
||||||
watch(dir.data(`static`), async (event, filename) => {
|
if (filename) {
|
||||||
if (filename) {
|
cache.dev = {};
|
||||||
cache.dev = {};
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
watch(dir.path("app/web/public"), async (event, filename) => {
|
||||||
|
if (filename) {
|
||||||
|
cache.dev = {};
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await Promise.all([this.load("app/static"), this.load("app/web/public")]);
|
await Promise.all([
|
||||||
|
this.load(dir.data("static")),
|
||||||
|
this.load(dir.path("app/web/public")),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async load(base_path: string) {
|
async load(base_path: string) {
|
||||||
try {
|
try {
|
||||||
const glob = new Bun.Glob("**");
|
const glob = new Bun.Glob("**");
|
||||||
|
|
||||||
for await (const file_path of glob.scan(dir.path(base_path))) {
|
for await (const file_path of glob.scan(base_path)) {
|
||||||
const r_path = dir.path(`${base_path}/${file_path}`);
|
const r_path = `${base_path}/${file_path}`;
|
||||||
const br_path = dir.path(`${base_path}-br/${file_path}`);
|
const br_path = `${base_path}-br/${file_path}`;
|
||||||
|
|
||||||
let final_path = r_path;
|
let final_path = r_path;
|
||||||
let br = false;
|
let br = false;
|
||||||
|
|
@ -140,7 +147,7 @@ navigator.serviceWorker.getRegistration().then(function(reg) {
|
||||||
return new Response(cache.dev[url.pathname]);
|
return new Response(cache.dev[url.pathname]);
|
||||||
}
|
}
|
||||||
|
|
||||||
let file = Bun.file(dir.path(`/app/static${url.pathname}`));
|
let file = Bun.file(dir.data(`static${url.pathname}`));
|
||||||
if (await file.exists()) {
|
if (await file.exists()) {
|
||||||
cache.dev[url.pathname] = file;
|
cache.dev[url.pathname] = file;
|
||||||
return new Response(file);
|
return new Response(file);
|
||||||
|
|
@ -150,7 +157,7 @@ navigator.serviceWorker.getRegistration().then(function(reg) {
|
||||||
cache.dev[url.pathname] = file;
|
cache.dev[url.pathname] = file;
|
||||||
return new Response(file);
|
return new Response(file);
|
||||||
}
|
}
|
||||||
file = Bun.file(dir.path(`/app/static/index.html`));
|
file = Bun.file(dir.data(`static/index.html`));
|
||||||
if (await file.exists()) {
|
if (await file.exists()) {
|
||||||
cache.dev[`/index.html`] = file;
|
cache.dev[`/index.html`] = file;
|
||||||
return new Response(file);
|
return new Response(file);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import { platform } from "os";
|
||||||
|
|
||||||
const decoder = new TextDecoder();
|
const decoder = new TextDecoder();
|
||||||
export const parcelBuild = async () => {
|
export const parcelBuild = async () => {
|
||||||
await dirAsync("app/static");
|
await dirAsync(dir.data("static"));
|
||||||
|
|
||||||
const args = [
|
const args = [
|
||||||
"node",
|
"node",
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ export const preparePrisma = async () => {
|
||||||
(await existsAsync(dir.path("app/db/.env"))) ||
|
(await existsAsync(dir.path("app/db/.env"))) ||
|
||||||
process.env.DATABASE_URL
|
process.env.DATABASE_URL
|
||||||
) {
|
) {
|
||||||
if (g.mode === "prod" && exists(dir.path("app/static-br"))) {
|
if (g.mode === "prod" && exists(dir.data("static-br"))) {
|
||||||
g.log.info("Prisma: db pull & generate");
|
g.log.info("Prisma: db pull & generate");
|
||||||
await $({ cwd: dir.path(`app/db`) })`bun prisma db pull`;
|
await $({ cwd: dir.path(`app/db`) })`bun prisma db pull`;
|
||||||
await $({ cwd: dir.path(`app/db`) })`bun prisma generate`;
|
await $({ cwd: dir.path(`app/db`) })`bun prisma generate`;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue