timse / srcset-loader

Flexible srcset-loader for webpack
46 stars 14 forks source link

Don’t process with sharp if same width #22

Closed drwpow closed 10 months ago

drwpow commented 6 years ago

The original intention of the check was to skip upscaling, but skipping Sharp processing if a user requests an image of the original size would also be ideal, both from a perf perspective, and Sharp ruining some files if it unnecessarily touches them (such as animated GIFs—see https://github.com/lovell/sharp/issues/245).

I was able to successfully build in my project, so this seems to be working. This actually solves a really big problem for me (Sharp killing animated GIFs), but I’d love to know if this causes undue side effects I’m not considering.

drwpow commented 6 years ago

Additional info: it looks src-loader should be able to require an image without specifying ?sizes, but when I tried omitting that param I ended up with ?size=undefined as the resource name in the webpack manifest. That caused issues for me.

If that is the ideal solution—making sure omitting sizes works—rather than this PR, I’d love to help with that instead.