Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishi Raj Jain authored Apr 3, 2024
1 parent bec2c73 commit ca7089f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/astro-font/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

<img width="1214" alt="Screenshot 2024-03-21 at 7 39 51 AM" src="https://github.com/rishi-raj-jain/astro-font/assets/46300090/3572601b-ec47-4c8e-a9fd-f7cc51b60ff0">

#### 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

Expand Down

0 comments on commit ca7089f

Please sign in to comment.