Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion apps/web/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,39 @@ import cloudflare from "@astrojs/cloudflare";
import react from "@astrojs/react";
import sanity from "@sanity/astro";
import tailwindcss from "@tailwindcss/vite";
import fs from "node:fs";
import path from "node:path";

// Sanity config — dataset comes from env var (set by wrangler vars or .env)
// In astro.config.mjs, .env files are NOT loaded — use process.env
const sanityProjectId = process.env.SANITY_PROJECT_ID || "hfh83o0w";
const sanityDataset = process.env.SANITY_DATASET || "production";

/**
* Vite plugin to inline font files as Uint8Array at build time.
* Required for OG image generation on CF Workers (no filesystem access).
*/
function rawFonts(extensions) {
return {
name: "vite-plugin-raw-fonts",
enforce: "pre",
resolveId(id, importer) {
if (extensions.some((ext) => id.includes(ext))) {
if (id.startsWith(".")) {
return path.resolve(path.dirname(importer), id);
}
return id;
}
},
load(id) {
if (extensions.some((ext) => id.includes(ext))) {
const buffer = fs.readFileSync(id);
return `export default new Uint8Array([${Array.from(buffer).join(",")}]);`;
}
},
};
}

export default defineConfig({
output: "server",
adapter: cloudflare({
Expand All @@ -31,6 +58,11 @@ export default defineConfig({
react(),
],
vite: {
plugins: [tailwindcss()],
plugins: [tailwindcss(), rawFonts([".ttf", ".otf"])],
assetsInclude: ["**/*.wasm"],
assetsExclude: ["**/*.ttf", "**/*.otf"],
ssr: {
external: ["buffer", "path", "fs"].map((i) => `node:${i}`),
},
},
});
182 changes: 173 additions & 9 deletions apps/web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading