I'm trying to use preload for a font in a project that was bootstrapped with create-react-app.
I added this tag to my index.html file:
<link rel="preload" href="%PUBLIC_URL%/myFontFile.woff2" as="font" type="font/woff2">
But my problem is that I don't know how to reference this font file from my CSS (in the @font-face url). The CSS file is not in the public folder.
A different option might be to put the font file into /src but then I don't know what the file name of my font file is in the preload tag because it gets assigned a random id when there is a new version of it & webpack builds the project.
I know that I can put the CSS together with the font file into the public folder but that will mean that this CSS doesn't get bundled.
What is the best approach to get preload to work with create-react-app (no eject) and have the CSS with the @font-face declaration bundled together with the other CSS files?
Or if this is not really possible: what are my alternatives where I can get a similar behaviour to preload for my font loading?