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({
236
236
fontAssetsDir: ' public/assets/fonts' ,
237
237
238
238
// 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 )
240
243
})
241
244
}),
242
245
],
Original file line number Diff line number Diff line change @@ -40,6 +40,11 @@ export interface LocalFontProcessorOptions {
40
40
* @default '/assets/fonts'
41
41
*/
42
42
fontServeBaseUrl ?: string
43
+
44
+ /**
45
+ * Custom fetch function to provide the font data.
46
+ */
47
+ fetch ?: typeof fetch
43
48
}
44
49
45
50
export function createLocalFontProcessor ( options ?: LocalFontProcessorOptions ) : WebFontProcessor {
@@ -50,7 +55,8 @@ export function createLocalFontProcessor(options?: LocalFontProcessorOptions): W
50
55
const fontServeBaseUrl = options ?. fontServeBaseUrl || '/assets/fonts'
51
56
52
57
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 )
54
60
. then ( r => r . arrayBuffer ( ) )
55
61
await fsp . mkdir ( fontAssetsDir , { recursive : true } )
56
62
await fsp . writeFile ( assetPath , Buffer . from ( response ) )
You can’t perform that action at this time.
0 commit comments