Skip to content

fix: report public urls for fonts in bundler-emitted css - #982

Merged
danielroe merged 1 commit into
mainfrom
fix/resolved-relative-urls
Nov 25, 2026
Merged

danielroe merged 1 commit into
mainfrom
fix/resolved-relative-urls

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

📚 Description

when the bundler emits a stylesheet itself, fonts:resolved reports font URLs relative to that stylesheet. in a production build the hook reports:

./fonts/5G5fwyXVs8aD-....woff2

which nuxt-og-image v7 fetches from the site root at runtime. it gets HTML back and skips the family:

[@nuxtjs/og-image]  WARN  OG images skip font "Barlow" (./fonts/5G5fwyXVs8aD-....woff2) because it is not a TTF, OTF, WOFF or WOFF2 file. Serve it as TTF, OTF, WOFF or WOFF2.

this PR resolves the re-emitted faces against the font asset directory as well, so the hook reports the path the font is served from.

spotted in danielroe/roe.dev#1998

@harlan-zw, do you think this is the right fix?

@danielroe
danielroe requested a review from harlan-zw November 24, 2026 21:50
@pkg-pr-new

pkg-pr-new Bot commented Nov 24, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/nuxt/fonts/@nuxt/fonts@982

commit: 6d299c6

@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

For rendered fonts, resolveFontDetails now forms the source URL and file-map key from the base URL, assetsBaseURL and filename. New tests check resolved font URLs, file URLs and stylesheet font paths with and without a configured base URL.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: Minimal · up to 6d299 · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: fonts reported by fonts:resolved in bundler-emitted CSS now use public URLs. The raw summary confirms resolveFontDetails now joins the base URL, assetsBaseURL and file…
Description check Passed The description explains the problem (fonts:resolved reports stylesheet-relative URLs such as ./fonts/...woff2 in production builds, which nuxt-og-image v7 cannot fetch) and the fix (resolving re-emit…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: fonts reported by fonts:resolved in bundler-emitted CSS now use public URLs. The raw summary confirms resolveFontDetails now joins the base URL, assetsBaseURL and filename for rendered fonts, matching the title's fix.

Full details: Description check

Explanation

The description explains the problem (fonts:resolved reports stylesheet-relative URLs such as ./fonts/...woff2 in production builds, which nuxt-og-image v7 cannot fetch) and the fix (resolving re-emitted faces against the font asset directory). This relates directly to the changeset in src/assets.ts and the added tests.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5d9b2887-9133-463d-9e03-fdad8b719ff5
Commits

Reviewing files that changed from the base of the PR and between 4b8a288 and 6d299c6.

Files ignored due to path filters: 1

  • test/fixtures/resolved-hook-unocss/fonts/Barlow-400.woff2 is excluded by !**/*.woff2
Files selected for processing: 3

  • src/assets.ts
  • test/resolved-hook-unocss-baseurl.test.ts
  • test/resolved-hook-unocss.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 71.32%. Comparing base (4b8a288) to head (6d299c6).

Files with missing lines Patch % Lines
src/assets.ts 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #982      +/-   ##
==========================================
+ Coverage   71.18%   71.32%   +0.13%     
==========================================
  Files          20       20              
  Lines         923      924       +1     
  Branches      259      259              
==========================================
+ Hits          657      659       +2     
  Misses        220      220              
+ Partials       46       45       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@harlan-zw

Copy link
Copy Markdown
Contributor

Looks good, this fixes it on og images side nuxt-modules/og-image#805

@danielroe
danielroe added this pull request to the merge queue Nov 25, 2026
Merged via the queue into main with commit 9a33f5a Nov 25, 2026
12 checks passed
@danielroe
danielroe deleted the fix/resolved-relative-urls branch November 25, 2026 13:33
@github-actions github-actions Bot mentioned this pull request Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants