Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

232
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda