storytellurx-v1/dev.ts
Elias Rhouzlane 75c3c9cefb build: runtimeRootURL follows RSC_BUILD_BASE_URL, the platform that runs the app says where it runs
dev.ts pinned file:///app/src/, Deno Deploy's run path. MF runs the app at /app, so the module map named
paths that do not exist there. RSC_BUILD_BASE_URL wins when set, the default is unchanged.

Claude-Session: https://claude.ai/code/session_01SMfX9gSZ3LVkJ3EJP8NaW6
2026-10-24 19:03:41 +02:00

44 lines
1.6 KiB
TypeScript

import { build } from "@bureaudouble/rsc/build";
import { createCachedFetch } from "@bureaudouble/antichamber";
import postcss from "postcss";
import postcssPresetEnv from "postcss-preset-env";
import tailwindcss from "@tailwindcss/postcss";
const maincss = import.meta.resolve("./main.css");
const tw = await createCachedFetch(
{
runImmediate: true,
cachePath: import.meta.resolve("./build/tailwind/snapshot.json"),
pathname: (hash) => `/styles.${hash}.css`,
loader: async () => {
const processor = postcss([
tailwindcss({ optimize: { minify: true }, base: Deno.cwd() }),
postcssPresetEnv({ browsers: "last 5 Safari major versions" }),
]);
const css = await fetch(maincss).then((r) => r.text());
const from = new URL(maincss).pathname;
const result = await processor.process(css, { from });
return { content: result.css, contentType: "text/css;charset=UTF-8" };
},
},
);
Array.fromAsync(Deno.watchFs(new URL(maincss).pathname), tw.updateCache);
globalThis.addEventListener("hmr", tw.updateCache);
await build({
publicPath: "/build/",
outputDirURL: new URL(import.meta.resolve("./build/")),
actionEndpoint: "/_rsc/action",
memberConfigPath: new URL(import.meta.resolve("./deno.json")),
runtimeRootURL: new URL(Deno.env.get("RSC_BUILD_BASE_URL") || "file:///app/src/"),
entrypoint: new URL(import.meta.resolve("./main.ts")),
});
export default Deno.args.includes("build")
? Deno.exit(0)
: import("./main.ts").then((m) =>
Deno.serve({ port: +(Deno.env.get("PORT") ?? "8000") }, m.default.fetch)
.finished
);