Add feature to skip unchanged images during refresh
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 |
|---|---|
![]() |
![]() |
It detects and converts newly added/modified images:

Webpack 4: ~1300ms → ~350ms
| Original | With skipUnchanged |
|---|---|
![]() |
![]() |
Hi @iampava, would you kindly take a look at this? I would appreciate it so much!
+1
+1
+1
+1
+1
+1
+1
+1
+1
@iampava Please review this. Seems like a really amazing feature to have.



