Skip to content
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

Add feature to skip unchanged images during refresh #76

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

nerikosans
Copy link

Hello, thank you for publishing this great plugin.

This pull request fixes #14 , adding skipUnchanged option.

Implementation Summary

When skipUnchanged is true, it stores the SHA-256 hash value of each images to be converted. Like below:

// ImageminWebpWebpackPlugin.sourceVersions
{
  'assets/bicycle_2.webp': 'e3ab38b7bea9e13f7ec748019a92e45b8c13dbafcb612cb07ef59f6dc346a866',
  'assets/cookie-monster.webp': 'ef8a7672e385b4ab734129baf16db2597b19547580c9a88f9a1c81b5faa54953',
  'assets/images/folder.with.dots/inner-folder/bicycle_1.webp': '93cc700fbf54c93c9503166343c9f3d2bfcbc98d2049bc38972e8501d8c26c20'
}

Then during refreshes, conversions are skipped if the target image's hash is already stored.

Note: This implementation is inspired by an official example from webpack for monitoring changed chunks.
https://webpack.js.org/contribute/plugin-patterns/#changed-chunks

Experimental results

Experiments on test projects showed this change saves a considerable ratio of runtime. 🎉

Webpack 5: ~800ms → ~150ms

Original With skipUnchanged
screenshot 2022-03-14 16 46 18 screenshot 2022-03-14 16 45 46

It detects and converts newly added/modified images:
screenshot 2022-03-14 17 48 49

Webpack 4: ~1300ms → ~350ms

Original With skipUnchanged
screenshot 2022-03-14 16 49 23 screenshot 2022-03-14 16 50 56

@nerikosans nerikosans mentioned this pull request Mar 14, 2022
@nerikosans
Copy link
Author

Hi @iampava, would you kindly take a look at this? I would appreciate it so much!

@georgi-vdimitrov
Copy link

+1

8 similar comments
@XenBG
Copy link

XenBG commented May 30, 2022

+1

@vdzhorov
Copy link

vdzhorov commented Jun 1, 2022

+1

@lmarkov
Copy link

lmarkov commented Jun 1, 2022

+1

@gwustick
Copy link

gwustick commented Jun 1, 2022

+1

@deaniliev
Copy link

+1

@mladen-venkov
Copy link

+1

@Radnevec
Copy link

Radnevec commented Jun 1, 2022

+1

@PlamBG
Copy link

PlamBG commented Jun 2, 2022

+1

@smisra3
Copy link

smisra3 commented Dec 6, 2022

@iampava Please review this. Seems like a really amazing feature to have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cache option