Volto: How to add a preload for fonts that are imported by webpack

I'm using fontsource to self-host my fonts. I'm importing the font into theme.js like so:

import '@fontsource/public-sans/700-italic.css';

This results in a URL like so:


Notice the 4815f9a9 at the end of the URL? This hash is added by webpack and makes it pretty difficult to add a <link rel="preload" href="{fontUrl}" as="font" t> to the HTML. Is there a reliable way of getting the hashed (and guaranteeing it matches what's imported in theme.js) URL for me to preload the font? Or will I need to deep-dive into webpack land and get webpack to add the preload for me somehow?

you might be able to get them by reading the sourcemap in server.jsx, but I'm not sure how you would inject that bit of extra links without customizations. Maybe with an AppExtras?

This can be done with the help of preload webpack plugin.