generate fallback font and preload automatically using vite-font#1538
generate fallback font and preload automatically using vite-font#1538rishi-raj-jain wants to merge 3 commits into
Conversation
WalkthroughThe website now integrates 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@website/src/components/Head.tsx`:
- Around line 84-86: Add the crossorigin value to each font preload rendered by
the fontPreloads.map block in Head, preserving the mapped value when present and
setting it to anonymous as required for these font requests.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b47c4767-614f-4648-bbd4-8ec5ad1655b8
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (6)
pnpm-workspace.yamlwebsite/package.jsonwebsite/src/components/Head.tsxwebsite/src/styles/root.csswebsite/tsconfig.jsonwebsite/vite.config.ts
There was a problem hiding this comment.
Review completed against the latest diff
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@website/src/components/Head.tsx`:
- Around line 84-95: Remove the outer duplicate fontPreloads.map wrapper in the
Head component, leaving a single map that renders each preload link once and
preserves the existing link properties.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ac2de9b8-7f80-4029-bf91-e3c0147835f1
📒 Files selected for processing (1)
website/src/components/Head.tsx
There was a problem hiding this comment.
1 issue found and verified against the latest diff
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="website/src/components/Head.tsx">
<violation number="1" location="website/src/components/Head.tsx:84">
P0: No `<link>` preload elements are rendered because the outer fontPreloads.map wraps the inner one in a JSX expression that produces objects instead of link elements. Remove the outer map wrapper entirely — it's a duplicate nesting that breaks the preload rendering.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
Hi. Thanks for bringing this to my attention. Are there any other ways to fix this? Is it possible to find some system fonts and set them as fallbacks via font-display? I can't accept the current solution because this library was released a week ago and has 60 installations per week. This could be dangerous. |
Before:

After:

Saved nearly a KB with vite-font, allows to configure fonts css via config (js), generates and emits a fallback font to be used so no layout shift happens.
Disclaimer: I'm the author of vite-font
Summary by CodeRabbit