diff --git a/packages/astro-font/README.md b/packages/astro-font/README.md index 2964817..5de80c4 100644 --- a/packages/astro-font/README.md +++ b/packages/astro-font/README.md @@ -25,12 +25,35 @@ pnpm add astro-font - `node:path` - `node:buffer` +#### Step 1. Enable nodejs_compat + To make sure that it works in Cloudflare Workers, please enable the `node_compatibiliy` flag per the guide https://developers.cloudflare.com/workers/runtime-apis/nodejs/#enable-nodejs-with-workers. If the above guide fails to work, go to your **Cloudflare project > Settings > Functions > Compatibility flags** and add the flag (as follows). Screenshot 2024-03-21 at 7 39 51 AM +#### Step 2. Opt out of bundling Node.js built-ins + +Per [Astro + Cloudflare docs](https://docs.astro.build/en/guides/integrations-guide/cloudflare/#nodejs-compatibility), you'd need to modify the vite configuration to allow for the node:* import syntax: + +```diff +// File: astro.config.mjs + +import { defineConfig } from 'astro/config'; +import cloudflare from '@astrojs/cloudflare'; + +// https://astro.build/config +export default defineConfig({ + output: 'server', + adapter: cloudflare(), ++ vite: { ++ ssr: { ++ external: ['node:buffer', 'node:path', 'node:fs', 'node:os'], ++ }, ++ }, +}); +``` ## Google Fonts