diff --git a/src/bake/client/overlay.ts b/src/bake/client/overlay.ts index 360d192b57..8ec108ed8b 100644 --- a/src/bake/client/overlay.ts +++ b/src/bake/client/overlay.ts @@ -125,6 +125,7 @@ interface CodePreview { interface RemappedFrame extends Frame {} +declare const OVERLAY_CSS: string; /** * Initial mount is done lazily. The modal starts invisible, controlled * by `setModalVisible`. @@ -144,7 +145,7 @@ function mountModal() { }); const shadow = domShadowRoot.attachShadow({ mode: "open" }); const sheet = new CSSStyleSheet(); - sheet.replace(css("client/overlay.css", IS_BUN_DEVELOPMENT)); + sheet.replace(OVERLAY_CSS); shadow.adoptedStyleSheets = [sheet]; const root = elem("div", { class: "root" }, [ diff --git a/src/bake/macros.ts b/src/bake/macros.ts deleted file mode 100644 index 4fa74f3e27..0000000000 --- a/src/bake/macros.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { readFileSync } from "node:fs"; -import { resolve } from "node:path"; - -// @ts-ignore -export async function css(file: string, is_development: boolean): string { - const { success, stdout, stderr } = await Bun.spawnSync({ - cmd: [process.execPath, "build", file, "--minify"], - cwd: import.meta.dir, - stdio: ["ignore", "pipe", "pipe"], - }); - if (!success) throw new Error(stderr.toString("utf-8")); - return stdout.toString("utf-8"); -} diff --git a/src/codegen/bake-codegen.ts b/src/codegen/bake-codegen.ts index d0b6a1f948..08a9825133 100644 --- a/src/codegen/bake-codegen.ts +++ b/src/codegen/bake-codegen.ts @@ -30,6 +30,16 @@ function convertZigEnum(zig: string, names: string[]) { return output; } +function css(file: string, is_development: boolean): string { + const { success, stdout, stderr } = Bun.spawnSync({ + cmd: [process.execPath, "build", file, "--minify"], + cwd: import.meta.dir, + stdio: ["ignore", "pipe", "pipe"], + }); + if (!success) throw new Error(stderr.toString("utf-8")); + return stdout.toString("utf-8"); +} + async function run() { const devServerZig = readFileSync(join(base_dir, "DevServer.zig"), "utf-8"); writeIfNotChanged(join(base_dir, "generated.ts"), convertZigEnum(devServerZig, ["IncomingMessageId", "MessageId"])); @@ -43,6 +53,7 @@ async function run() { side: JSON.stringify(side), IS_ERROR_RUNTIME: String(file === "error"), IS_BUN_DEVELOPMENT: String(!!debug), + OVERLAY_CSS: css("../bake/client/overlay.css", !!debug), }, minify: { syntax: !debug,