Skip to content

fix(docs): bundle navigation icons to prevent client-nav flash#2288

Draft
benjamincanac wants to merge 2 commits into
mainfrom
chore/icon-scan-glob
Draft

fix(docs): bundle navigation icons to prevent client-nav flash#2288
benjamincanac wants to merge 2 commits into
mainfrom
chore/icon-scan-glob

Conversation

@benjamincanac

@benjamincanac benjamincanac commented Jun 25, 2026

Copy link
Copy Markdown
Member

Problem

Docs navigation icons (e.g. on /docs/4.x/getting-started/installation) flash in on client-side navigation. They render in @nuxt/icon's CSS mode (class="iconify i-lucide:book-marked"). On a hard refresh the mask CSS is inlined via SSR (onServerPrefetch), so it's fine — but on client-side route changes the icon data isn't in the client bundle, so it's fetched from the iconify API and the CSS rule is injected after paint → flash.

Icons used only by the remote docs nav (md frontmatter navigation.icon + .navigation.yml) can't be collected automatically at build time:

  • clientBundle.scan skips them — remote docs are cloned under the .data dot-dir, ignored under tinyglobby dot:false.
  • Parse hooks (content:file:beforeParse) don't help — @nuxt/content restores its cache on CI (✔ … 972 cached, 0 parsed), so nothing is parsed and the hook never fires.
  • Globbing the raw .data/content files doesn't help either — repos aren't re-cloned on cached CI builds.

(All three verified empirically with local builds.)

Fix

Inline the remote-docs-only icon list into icon.clientBundle.icons — the only build-state-independent source (data loaded from the installed @iconify-json/* packages at build). Collected across all three served versions (nuxt/nuxt 3.x, 4.x, main) — important because some icons are version-specific (e.g. vscode-icons:folder-type-app only appears in 4.x's app/ directory structure). Every entry is validated against the installed packages (an unresolved clientBundle.icons entry would fail a production build).

Local content (deploy, blog, …) and app icons stay covered by scan; its glob is widened to include .ts (app config) and **/.*.{yml,yaml} (local .navigation.yml dotfiles).

Refreshing the list

Regenerate when docs add icons — grep all three branches for i-<collection>-<name> and subtract what scan already covers (app + local content/).

Verification

Local production build: client bundle 215 → 262 icons (143.57 KB, under the 256 KB limit), including all folder-type-*/file-type-* docs nav icons. Cross-checked the 3.x/4.x/main branches against the bundle — initial main-only list missed vscode-icons:folder-type-app + simple-icons:google; both now included.

@benjamincanac benjamincanac requested a review from atinux as a code owner June 25, 2026 13:49
@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nuxt Ready Ready Preview, Comment Jun 25, 2026 4:18pm

@benjamincanac benjamincanac changed the title chore(icon): scan ts files and local navigation.yml for client bundle fix(nuxt.config): scan .ts files and navigation.yml for client bundle Jun 25, 2026
@benjamincanac benjamincanac changed the title fix(nuxt.config): scan .ts files and navigation.yml for client bundle fix(nuxt.config): scan .ts and navigation.yml for client bundle Jun 25, 2026
@benjamincanac benjamincanac changed the title fix(nuxt.config): scan .ts and navigation.yml for client bundle fix(nuxt.config): scan .ts and navigation.yml for icon client bundle Jun 25, 2026
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The client bundle icon scan setting now uses an explicit globInclude pattern list instead of a boolean flag. The listed patterns cover Vue, JavaScript, TypeScript, Markdown, MDC, YAML, YML, and dot-prefixed YAML/YML files.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~4 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Description check ✅ Passed The description discusses the same icon bundle scanning change and the added file patterns in nuxt.config.ts.
Title check ✅ Passed The title accurately summarizes the main change: bundling navigation icons at build time to avoid client-side flashes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/icon-scan-glob

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

Comment @coderabbitai help to get the list of available commands.

@benjamincanac benjamincanac marked this pull request as draft June 25, 2026 14:16
@benjamincanac benjamincanac changed the title fix(nuxt.config): scan .ts and navigation.yml for icon client bundle fix(icon): prevent docs navigation icons flashing on client nav Jun 25, 2026
@benjamincanac benjamincanac changed the title fix(icon): prevent docs navigation icons flashing on client nav fix(docs): prevent navigation icons flashing on client nav Jun 25, 2026
@benjamincanac benjamincanac force-pushed the chore/icon-scan-glob branch from 97073bd to 0feee38 Compare June 25, 2026 15:38
@benjamincanac benjamincanac changed the title fix(docs): prevent navigation icons flashing on client nav fix(icon): bundle docs navigation icons to prevent client-nav flash Jun 25, 2026
@benjamincanac benjamincanac force-pushed the chore/icon-scan-glob branch from 0feee38 to 5f66098 Compare June 25, 2026 15:46
Docs nav icons render in @nuxt/icon CSS mode. On initial load their mask CSS
is inlined via SSR, but on client-side navigation the icon data isn't in the
client bundle, so it's fetched from the iconify API and the rule is injected
after paint — a visible flash.

The icons used only by the remote nuxt/nuxt docs nav (md frontmatter
`navigation.icon` + `.navigation.yml`) can't be collected automatically:
- the scanner skips the `.data` dot-dir (remote docs), and
- @nuxt/content restores its cache on CI (0 files parsed), so parse hooks and
  raw-file globbing both come up empty at build time.

Inline just those remote-only icons (validated against the installed
@iconify-json packages). Local content (deploy, blog, …) and app icons stay
covered by `scan`; widen its glob to include `.ts` and `**/.*.{yml,yaml}`
so app config and local `.navigation.yml` dotfiles are picked up too.

Verified: client bundle 215 -> 262 icons (143.57KB, under the 256KB limit),
including all folder-type/file-type docs nav icons; local icons (azure, blog
nav) confirmed still bundled via the scanner.
@benjamincanac benjamincanac force-pushed the chore/icon-scan-glob branch from 5f66098 to 9357ace Compare June 25, 2026 15:50
@benjamincanac benjamincanac changed the title fix(icon): bundle docs navigation icons to prevent client-nav flash fix(docs): bundle navigation icons to prevent client-nav flash Jun 25, 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.

1 participant