1
1
import fsp from 'node:fs/promises'
2
- import { addDevServerHandler , useNuxt } from '@nuxt/kit'
2
+ import { addDevServerHandler , useLogger , useNuxt } from '@nuxt/kit'
3
3
import { eventHandler , createError } from 'h3'
4
4
import { fetch } from 'ofetch'
5
5
import { defu } from 'defu'
@@ -16,6 +16,7 @@ import type { FontFaceData, ModuleOptions, NormalizedFontFaceData } from './type
16
16
export function setupPublicAssetStrategy ( options : ModuleOptions [ 'assets' ] = { } ) {
17
17
const assetsBaseURL = options . prefix || '/_fonts'
18
18
const nuxt = useNuxt ( )
19
+ const logger = useLogger ( '@nuxt/fonts' )
19
20
const renderedFontURLs = new Map < string , string > ( )
20
21
21
22
function normalizeFontData ( faces : FontFaceData | FontFaceData [ ] ) : NormalizedFontFaceData [ ] {
@@ -79,6 +80,7 @@ export function setupPublicAssetStrategy (options: ModuleOptions['assets'] = {})
79
80
nitro . hooks . hook ( 'rollup:before' , async ( ) => {
80
81
await fsp . rm ( cacheDir , { recursive : true , force : true } )
81
82
await fsp . mkdir ( cacheDir , { recursive : true } )
83
+ logger . info ( 'Downloading uncached fonts...' )
82
84
for ( const [ filename , url ] of renderedFontURLs ) {
83
85
const key = 'data:' + filename
84
86
// Use nitro.storage to cache the font data between builds
0 commit comments