Skip to content

Commit 9357ace

Browse files
committed
fix(icon): bundle docs navigation icons to prevent client-nav flash
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.
1 parent d0ce856 commit 9357ace

1 file changed

Lines changed: 30 additions & 2 deletions

File tree

nuxt.config.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,36 @@ export default defineNuxtConfig({
553553
dir: resolve('./app/assets/icons')
554554
}],
555555
clientBundle: {
556-
scan: true,
557-
includeCustomCollections: true
556+
// Scan app source + all local content for icons. The `**/.*.{yml,yaml}`
557+
// pattern is needed for local `.navigation.yml` dotfiles (e.g. blog,
558+
// enterprise), which `*.yml` skips under `dot:false`.
559+
scan: {
560+
globInclude: ['**/*.{vue,jsx,tsx,md,mdc,mdx,yml,yaml,ts}', '**/.*.{yml,yaml}']
561+
},
562+
includeCustomCollections: true,
563+
// Icons used ONLY by the remote docs navigation (md frontmatter
564+
// `navigation.icon` + `.navigation.yml`), collected across all three served
565+
// versions (nuxt/nuxt `3.x`, `4.x`, `main`). The scanner can't reach these:
566+
// remote docs are cloned under the `.data` dot-dir and restored from
567+
// @nuxt/content's cache on CI (0 files parsed), so neither file scanning nor
568+
// parse hooks see them at build. Without bundling they're fetched at runtime
569+
// and flash in on client-side navigation. Local content (deploy, blog, …) is
570+
// already covered by `scan` above, so it's intentionally NOT here.
571+
// Regenerate when nuxt/nuxt docs add icons (see PR #2288 for the snippet).
572+
icons: [
573+
'logos:bun', 'lucide:alert-triangle', 'lucide:arrow-left-right', 'lucide:bell-dot',
574+
'lucide:bug-off', 'lucide:cable', 'lucide:cog', 'lucide:cooking-pot',
575+
'lucide:map', 'lucide:panels-top-left', 'lucide:play', 'lucide:ship',
576+
'lucide:square-check', 'lucide:square-terminal', 'lucide:test-tube', 'lucide:toggle-right',
577+
'simple-icons:codesandbox', 'simple-icons:git', 'simple-icons:google', 'simple-icons:googlechrome',
578+
'simple-icons:mdnwebdocs', 'simple-icons:vite', 'simple-icons:w3c', 'simple-icons:webpack',
579+
'vscode-icons:default-folder', 'vscode-icons:file-type-dotenv', 'vscode-icons:file-type-git', 'vscode-icons:file-type-light-config',
580+
'vscode-icons:file-type-npm', 'vscode-icons:file-type-nuxt', 'vscode-icons:file-type-tsconfig', 'vscode-icons:file-type-vue',
581+
'vscode-icons:folder-type-app', 'vscode-icons:folder-type-asset', 'vscode-icons:folder-type-component', 'vscode-icons:folder-type-log',
582+
'vscode-icons:folder-type-middleware', 'vscode-icons:folder-type-node', 'vscode-icons:folder-type-nuxt', 'vscode-icons:folder-type-package',
583+
'vscode-icons:folder-type-plugin', 'vscode-icons:folder-type-public', 'vscode-icons:folder-type-server', 'vscode-icons:folder-type-shared',
584+
'vscode-icons:folder-type-src', 'vscode-icons:folder-type-temp', 'vscode-icons:folder-type-tools', 'vscode-icons:folder-type-view'
585+
]
558586
}
559587
},
560588
image: {

0 commit comments

Comments
 (0)