File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
packages-presets/preset-web-fonts/src Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -236,7 +236,10 @@ export default defineConfig({
236236 fontAssetsDir: ' public/assets/fonts' ,
237237
238238 // Base URL to serve the fonts from the client
239- fontServeBaseUrl: ' /assets/fonts'
239+ fontServeBaseUrl: ' /assets/fonts' ,
240+
241+ // Custom fetch function to download the fonts
242+ fetch : async url => axios .get (url )
240243 })
241244 }),
242245 ],
Original file line number Diff line number Diff line change @@ -40,6 +40,11 @@ export interface LocalFontProcessorOptions {
4040 * @default '/assets/fonts'
4141 */
4242 fontServeBaseUrl ?: string
43+
44+ /**
45+ * Custom fetch function to provide the font data.
46+ */
47+ fetch ?: typeof fetch
4348}
4449
4550export function createLocalFontProcessor ( options ?: LocalFontProcessorOptions ) : WebFontProcessor {
@@ -50,7 +55,8 @@ export function createLocalFontProcessor(options?: LocalFontProcessorOptions): W
5055 const fontServeBaseUrl = options ?. fontServeBaseUrl || '/assets/fonts'
5156
5257 async function _downloadFont ( url : string , assetPath : string ) {
53- const response = await fetch ( url )
58+ const fetcher = options ?. fetch ?? fetch
59+ const response = await fetcher ( url )
5460 . then ( r => r . arrayBuffer ( ) )
5561 await fsp . mkdir ( fontAssetsDir , { recursive : true } )
5662 await fsp . writeFile ( assetPath , Buffer . from ( response ) )
You can’t perform that action at this time.
0 commit comments