unplugin-fonts icon indicating copy to clipboard operation
unplugin-fonts copied to clipboard

[Bug]: Vite custom font scanning all available font files including node_modules

Open chunlampang opened this issue 1 year ago • 3 comments

Describe the feature

Since there are some font files (e.g. icon font) already handled by other plugin, unplugin-fonts is no need to inject those files. It just need to inject the configurated fonts instead of inject every available font files inside the build. It is suggested that adding an option to disable control custom font.

Update - it is a bug

Vite custom font scanning all available font files including node_modules file on build

chunlampang avatar Sep 13 '24 03:09 chunlampang

Are the following code repeated? https://github.com/cssninjaStudio/unplugin-fonts/blob/a7e66d594e2c7e0a2cccfed7c15a069ffebb96c1/src/index.ts#L92-L102 https://github.com/cssninjaStudio/unplugin-fonts/blob/a7e66d594e2c7e0a2cccfed7c15a069ffebb96c1/src/index.ts#L126-L136

chunlampang avatar Sep 27 '24 09:09 chunlampang

I'm hitting this as well, and this results in console warnings in my app, due to adding preload directives for fonts that are only used in async chunks that are not loaded with the app. This happens because the current code generates preload directives for all fonts in the bundle rather than only fonts included via custom which is undesirable IMHO.

segevfiner avatar Mar 12 '25 15:03 segevfiner

if you don't use custom fonts a quick fix is

UnpluginFonts({
  ...
  custom: {
    families: [],
    preload: false,
  },
}),

The proper way is probably to use linkFilter, but it's not in the docs

its2easy avatar Apr 29 '25 15:04 its2easy