-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable inline images for images that are less than 10,000 bytes #3437
Comments
I propose to do a pull request to add an environment variable that would be used here: https://github.com/facebookincubator/create-react-app/blob/36cd35d684f6f0eda971b30c789010758fc61ceb/packages/react-scripts/config/webpack.config.prod.js#L166 and here https://github.com/facebookincubator/create-react-app/blob/70e0c08ef7de8845b1a4c6700822e27e45b481a8/packages/react-scripts/config/webpack.config.dev.js#L159 and would fallback to 10000. |
Intriguing use case. Let's see what others have to say, but the third option is what I just mentioned. edit: this option currently cannot be modified or disabled |
Another point to consider when using url-loader's inlining: small changes in either CRA's chosen threshold, or asset sizes in an app can mean a previously working Content-Security-Policy ends up blocking newly-inlined assets due to lack of For sites that have correct long-lived cache control headers (especially those remembering to use the |
Here's another attempt to solve this: #6060 It's similar to the idea of |
Any progress on this proposal? |
My PR is conflicting now but I'm not sure how to ping/pester it for review. |
Adding my name to this because I don't want my images inlined! |
Websites dealing with CSP will likely add
The alternative for CSP is using a nonce-based approach, but it has the following drawbacks:
All in all, it would be way simpler to just have an option to disable inline images. #6060 gets my +1 👍 |
Messing with CSP just to bend-over-backward for this "flaw" in CRA isn't the right direction. I still think my pr should get reviewed and landed. And perhaps it should be changed to make the default minimum 0 bytes, meaning you have to deliberately set an env var if you want base64 inlining. Hey! If you're here and also don't want base64 inlining you can...
Instead, do this:
div.page { background: url(./bullet.png) no-repeat left center; do this instead: div.page { background: url(/static/bullet.png) no-repeat left center; You'll also need to |
But I want the images loaded, checksummed, optimized and whatnot. I just don't want them inlined. In my use case long strings are problematic (using React to render multipart emails). |
Hopefully #6060 gets the stamp of approval |
Pile on reason: I realized a .png was being added as "data:" instead of using a path. At first I thought it was the file type because the same image as a .jpg worked. I don't want to have to add "data:" to my CSP as it's not recommended for security reasons. I'd like to be able to basically disable this feature all together and always use the image path. |
Adding my name to this because I don't want my images inlined! |
We're in the exact same position as @Kizmar, images are being converted to
Ideally there would be a solution that enables us to keep our sites secure whilst still utilising the standard image processing (just without the base64 step). |
Thanks for this awesome project.
I recently get a warning during build telling me:
Analyzing the project dependencies, I discovered that the easiest and most significant improvement would be to get rid of these small images under 10,000 bytes that are imported as Data URI by webpack (it's 25% of the size of my app).
I don't see an option to disable the feature. Does it exists? If no I have currently 2 options that are:
Both options are a big loss so an option to change the current behaviour would be nice.
Thanks for your help
The text was updated successfully, but these errors were encountered: