Skip to content

Add feature to skip unchanged images during refresh#76

Open
nerikosans wants to merge 4 commits into
iampava:masterfrom
nerikosans:feature/caching-output
Open

Add feature to skip unchanged images during refresh#76
nerikosans wants to merge 4 commits into
iampava:masterfrom
nerikosans:feature/caching-output

Conversation

@nerikosans
Copy link
Copy Markdown

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
Copy Markdown
Author

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

@georgi-vdimitrov
Copy link
Copy Markdown

+1

8 similar comments
@XenBG
Copy link
Copy Markdown

XenBG commented May 30, 2022

+1

@vdzhorov
Copy link
Copy Markdown

vdzhorov commented Jun 1, 2022

+1

@lmarkov
Copy link
Copy Markdown

lmarkov commented Jun 1, 2022

+1

@gwustick
Copy link
Copy Markdown

gwustick commented Jun 1, 2022

+1

@deaniliev
Copy link
Copy Markdown

+1

@mladen-venkov
Copy link
Copy Markdown

+1

@Radnevec
Copy link
Copy Markdown

Radnevec commented Jun 1, 2022

+1

@PlamBG
Copy link
Copy Markdown

PlamBG commented Jun 2, 2022

+1

@smisra3
Copy link
Copy Markdown

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