Problem
Using UnoCSS preset (nimiq-css) that includes font declarations. @nuxt/fonts doesn't detect fonts defined in preset CSS because it only scans user CSS files, not preset internals.
Current Behavior
Root Cause (UPDATED)
CSS Scanning Timing Issue: @nuxt/fonts scans for font-family usage BEFORE UnoCSS transforms utilities (like font-sans) into actual font-family declarations. When fonts are only used via UnoCSS utilities, they're never detected.
Workaround
Use global: true to force font injection:
fonts: {
families: [
{ name: 'Mulish', provider: 'google', weights: [400, 600, 700], global: true },
{ name: 'Fira Mono', provider: 'google', weights: [400], global: true },
],
}
Ideal Solution
@nuxt/fonts should hook into UnoCSS's generated CSS instead of only scanning source files. This would enable auto-detection from:
- UnoCSS
theme.fontFamily configuration
- Utility class usage (
font-sans, font-mono, etc.)
- Preset font declarations
This requires integration with UnoCSS build pipeline to scan AFTER transformation.
Reference: nimiq-ui repository (commit: 68e96cd)
Problem
Using UnoCSS preset (nimiq-css) that includes font declarations. @nuxt/fonts doesn't detect fonts defined in preset CSS because it only scans user CSS files, not preset internals.
Current Behavior
@font-facefor Mulish/Fira Monofonts: falsein preset config to avoid double-loadingRoot Cause (UPDATED)
CSS Scanning Timing Issue: @nuxt/fonts scans for
font-familyusage BEFORE UnoCSS transforms utilities (likefont-sans) into actualfont-familydeclarations. When fonts are only used via UnoCSS utilities, they're never detected.Workaround
Use
global: trueto force font injection:Ideal Solution
@nuxt/fonts should hook into UnoCSS's generated CSS instead of only scanning source files. This would enable auto-detection from:
theme.fontFamilyconfigurationfont-sans,font-mono, etc.)This requires integration with UnoCSS build pipeline to scan AFTER transformation.
Reference: nimiq-ui repository (commit:
68e96cd)