From b1049ee7a655638e4bf3530d83a09f5470147cb0 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Tue, 20 Feb 2024 19:58:55 +0000 Subject: [PATCH] fix: log when we are downloading fonts --- src/assets.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/assets.ts b/src/assets.ts index 93200ab..de9ceca 100644 --- a/src/assets.ts +++ b/src/assets.ts @@ -1,5 +1,5 @@ import fsp from 'node:fs/promises' -import { addDevServerHandler, useNuxt } from '@nuxt/kit' +import { addDevServerHandler, useLogger, useNuxt } from '@nuxt/kit' import { eventHandler, createError } from 'h3' import { fetch } from 'ofetch' import { defu } from 'defu' @@ -16,6 +16,7 @@ import type { FontFaceData, ModuleOptions, NormalizedFontFaceData } from './type export function setupPublicAssetStrategy (options: ModuleOptions['assets'] = {}) { const assetsBaseURL = options.prefix || '/_fonts' const nuxt = useNuxt() + const logger = useLogger('@nuxt/fonts') const renderedFontURLs = new Map() function normalizeFontData (faces: FontFaceData | FontFaceData[]): NormalizedFontFaceData[] { @@ -79,6 +80,7 @@ export function setupPublicAssetStrategy (options: ModuleOptions['assets'] = {}) nitro.hooks.hook('rollup:before', async () => { await fsp.rm(cacheDir, { recursive: true, force: true }) await fsp.mkdir(cacheDir, { recursive: true }) + logger.info('Downloading uncached fonts...') for (const [filename, url] of renderedFontURLs) { const key = 'data:' + filename // Use nitro.storage to cache the font data between builds