fontsvuejs3vitepreload

ViteFonts adding fonts shows "preload" issue in console


I added the following code in vite.config.mts to add fonts:

plugins: [
    ViteFonts({
      google: {
        families: [{
          name: 'Roboto',
          styles: 'wght@100;300;400;500;700;900',
        },{
          name:'Noto+Sans+SC',
          styles: 'wght@100;300;400;500;700;900'
        }],
      },
    }),
],

I successfully used these two fonts in the project, but in the production environment, the console outputs "The resource was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriate as value and it is preloaded intentionally." at intervals. In the development environment, this warning does not appear.

I have no idea how this happen......

Since I did not include the font in the head, I cannot add type or modify preload attributes, and I have no clue.


Solution

  • It seems to be a bug of unplugin-fonts.Github issue #69

    Now I switch to use vite-plugin-webfont-dl.