This commit is contained in:
Rizky 2023-10-16 11:42:09 +07:00
parent 19b894c3b5
commit a3bc388218
4 changed files with 9 additions and 6 deletions

View File

@ -1,2 +1,2 @@
bun run build bun run build
ssh plansys@web.andromedia.co.id "cd /home/plansys/" ssh plansys@web.andromedia.co.id "cd /home/plansys/prasi/app && bun run deploy"

View File

@ -1,10 +1,11 @@
import { spawn } from "bun"; import { spawn } from "bun";
import { dir } from "dir"; import { dir } from "dir";
import { dirAsync, removeAsync } from "fs-jetpack"; import { removeAsync } from "fs-jetpack";
import { g } from "utils/global";
await removeAsync(dir.path("app/static")); await removeAsync(dir.path("app/static"));
await removeAsync(dir.path("app/web/.parcel-cache")); await removeAsync(dir.path("app/web/.parcel-cache"));
await removeAsync(dir.path("app/web/static"));
const args = [ const args = [
"node", "node",
dir.path("node_modules/.bin/parcel"), dir.path("node_modules/.bin/parcel"),

View File

@ -80,6 +80,7 @@ export const createServer = async () => {
g.log.error(e); g.log.error(e);
} }
const webPath = g.mode === "dev" ? "app/static" : "app/web/static";
try { try {
const found = cache.static[url.pathname]; const found = cache.static[url.pathname];
if (found && g.mode === "prod") { if (found && g.mode === "prod") {
@ -87,7 +88,7 @@ export const createServer = async () => {
res.headers.set("Content-Type", found.type); res.headers.set("Content-Type", found.type);
} }
const file = Bun.file(dir.path(`app/static${url.pathname}`)); const file = Bun.file(dir.path(`${webPath}${url.pathname}`));
if ((await file.exists()) && file.type !== "application/octet-stream") { if ((await file.exists()) && file.type !== "application/octet-stream") {
cache.static[url.pathname] = { cache.static[url.pathname] = {
type: file.type, type: file.type,
@ -101,7 +102,7 @@ export const createServer = async () => {
} }
try { try {
return new Response(Bun.file(dir.path(`app/static/index.html`)) as any); return new Response(Bun.file(dir.path(`${webPath}/index.html`)) as any);
} catch (e) { } catch (e) {
g.log.error(e); g.log.error(e);
return new Response("Loading..."); return new Response("Loading...");

View File

@ -2,7 +2,8 @@
"exclude": [ "exclude": [
".git", ".git",
"node_modules", "node_modules",
"app/static" "app/static",
"app/web/static",
], ],
"compilerOptions": { "compilerOptions": {
"lib": [ "lib": [