Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

231
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda