I have recently inherited a sizable React project, even though my experience with React is limited. Nonetheless, I am attempting to make improvements in areas where I feel confident.
An ongoing issue we are facing is the excessive size of our main CSS file, primarily due to the use of Data-URIs for images within background-image
properties, despite originally being set as relative URLs in the SASS files.
Given that these images are reused throughout the application, our final CSS file ends up containing multiple instances of the same embedded images!
The culprit appears to be react-scripts build
, which, according to the documentation found here:
To reduce server requests, images smaller than 10,000 bytes are returned as data URIs instead of paths.
This behavior is not desired. Is there a way to disable it? The project does not utilize Webpack or any other build tools/bundlers. My only option seems to be tweaking the scripts in package.json
.