mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #1038] [MERGED] fix(dev): self-host Google Fonts in dev mode #1040
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#1040
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/1038
Author: @james-elicx
Created: 5/3/2026
Status: ✅ Merged
Merged: 5/3/2026
Merged by: @james-elicx
Base:
main← Head:claude/stoic-rosalind-dcd524📝 Commits (1)
ca90964fix(dev): self-host Google Fonts in dev mode📊 Changes
5 files changed (+163 additions, -64 deletions)
View changed files
📝
packages/vinext/src/plugins/fonts.ts(+108 -60)➕
tests/e2e/app-router/font-google.spec.ts(+15 -0)➕
tests/fixtures/app-basic/app/font-google-test/layout.tsx(+19 -0)➕
tests/fixtures/app-basic/app/font-google-test/page.tsx(+8 -0)📝
tests/font-google.test.ts(+13 -4)📄 Description
Summary
The build pipeline already rewrites
next/font/googlecalls to embed self-hosted@font-faceCSS pointing at/<assetsDir>/_vinext_fonts/..., but the call-site rewrite was gated behindisBuild. In dev:.vinext/fonts/files into the dev server's served paths._selfHostedCSSis present, the shim no longer emits thefonts.googleapis.com<link>— so dev showed unstyled glyphs with no CDN fallback either.This PR:
_selfHostedCSSinjection) runs in dev too.configureServermiddleware that serves cached files directly from.vinext/fonts/under the same URL prefix_rewriteCachedFontCssToServedUrls()embeds.CONTENT_TYPESmap so dev and prod hand out identical MIME types.isBuildclosure variable and the dead{ }block left after removing the gate.Regression test
tests/e2e/app-router/font-google.spec.tsnavigates to a new/font-google-testroute in theapp-basicfixture that usesGeist+Geist_Mono, then:fonts.googleapis.comURL leaks into the HTML.<style data-vinext-fonts>block is present.Content-Type: font/woff2, and a real body. This is the layer that catches both the CDN-leakage and the middleware-broken regressions in one shot.The spec runs under the existing
app-routerPlaywright project, so no new CI matrix entry is needed.Test plan
vp test tests/font-google.test.ts tests/font-google-build.test.ts— 104 passedPLAYWRIGHT_PROJECT=app-router npx playwright test --project=app-router tests/e2e/app-router/font-google.spec.ts— passingapp-router/app-with-srcsince they importnext/font/local, which is a different plugin — but worth confirming nothing regresses)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.