FullHuman / postcss-purgecss

PostCSS plugin for purgecss
MIT License
91 stars 5 forks source link

Preload fonts #21

Open ram-you opened 5 years ago

ram-you commented 5 years ago

Hi, I have a problem with preload fonts in a nuxt project. As result, I would like to have something like that : <link rel="preload" href="/_nuxt/fonts/5b23eeb.woff2" as="font" type="font/woff2" crossorigin>

..from my nuxt.config.js:

....
  css: [
    '~assets/css/tailwind.css',
    '~assets/fonts/Ubuntu/index.css',
  ],
...
...
  render: {
    bundleRenderer: {
      shouldPreload: (file, type) => {
        if (type === 'font') return /.woff2/.test(file)
        return ['script', 'style'].includes(type)
      }
    }
  },
...

Can you help please? THANKS