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

140
Visualizações
Migrating to react-scripts@4 having problem with assets in css

I am migrating from react-scripts@3.4.3 to react-scripts@4.0.3 (main util of Create react app) and i have struggle with referencing images in the CSS files.

Previously I had in my CSS referenced URLs like:

.social.linkedin {
    background-color: #006699;
    background-image: url('/assets/socials/linkedin@2x.png');
}

.social.telegram {
    background-color: #28a0d3;
    background-image: url('/assets/socials/telegram@2x.png');
}

.social.github {
    background-color: #1b1f23;
    background-image: url('/assets/socials/github@2x.png');
}

React scripts just preserved these URLs during the transpilation and in the final bundle URLs were exactly the same as in source files. I have configured a server such as /assets path was served by CDN. Everything was working.

But in version 4.0.3 react-scripts are trying to be "smarter" and import images into the production build as data URI. They deal with them as other code imports and restrict their existence only to src folder or libraries.

Creating an optimized production build...
Failed to compile.

./src/35-styles/index.css
Error: Can't resolve '/assets/socials/github@2x.png' in 'C:\Users\me\work\collboard\collboard-merging\src\35-styles'
    at runMicrotasks (<anonymous>)

Can I somehow turn off this feature without referencing assets externally as absolute URLs or putting them into the src folder and having them as inefficient data URIs in the CSS bundle?

about 4 years ago · Juan Pablo Isaza
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