Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

230
Views
React CRA: Preload fonts from fonts folder

I am using react and using custom fonts via SCSS as:

@font-face {
  font-family: 'FiraGO Bold';
  src: url('../../fonts/FiraGO-Bold.woff2') format('woff2'),
    url('../../fonts/FiraGO-Bold.woff') format('woff');
  font-weight: bold;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'FiraGO Medium';
  src: url('../../fonts/FiraGO-Medium.woff2') format('woff2'),
    url('../../fonts/FiraGO-Medium.woff') format('woff');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'FiraGO';
  src: url('../../fonts/FiraGO-Regular.woff2') format('woff2'),
    url('../../fonts/FiraGO-Regular.woff') format('woff');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

// Fonts
:root {
  --font-base: 'FiraGO', sans-serif;
  --font-bold: 'FiraGO Bold', sans-serif;
  --font-medium: 'FiraGO Medium', sans-serif;
}

but I get to see this issue on the lighthouse enter image description here

I can just use preload in a link because this is not a hosted font and hence the font files are also hashed in the build.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

To do that you need to split the font file outside the SCSS build, for example, you can set it inside public HTML in the fonts directory and use it. (I do that for some of the external recourse and its work)

now how you can do that: (Example)

  <link rel="preload" href="fonts/cicle_fina-webfont.woff2" as="font" type="font/woff2" crossorigin>
  

and then you can add:

@font-face {
    font-family: 'ciclefina';
    src: url('fonts/cicle_fina-webfont.eot');
    src: url('fonts/cicle_fina-webfont.eot?#iefix') format('embedded-opentype'),
         url('fonts/cicle_fina-webfont.woff2') format('woff2'),
         url('fonts/cicle_fina-webfont.woff') format('woff'),
         url('fonts/cicle_fina-webfont.ttf') format('truetype'),
         url('fonts/cicle_fina-webfont.svg#ciclefina') format('svg');
    font-weight: normal;
    font-style: normal;
}

Or you can move fonts and CSS for these fonts to the public HTML directory and add preload direct in index.html

Or you can add to index.html: <link rel="preload" href="yourFont.woff2" as="font" />

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!