[Bug] `data:` protocol trigger error
Airkro opened this issue · 1 comments
Bug report
#270 add data:
protocol support.
It' will trigger errors in some cases.
Actual Behavior
import data:text/*
trigger error because, the implementation only accept image format
It also breaks html-webpack-plugin@5
, see that in reproduce sandbox.
Expected Behavior
Only data:image/*
included.
How Do We Reproduce?
https://codesandbox.io/s/image-minimizer-webpack-plugin-error-3qmbi?file=/webpack.config.js
Please paste the results of npx webpack-cli info
here, and mention other relevant information
From my case:
ERROR in data:text/abc,1231
Module Error (from ./node_modules/image-minimizer-webpack-plugin/dist/loader.js):
not image
Error: not image
at Object.implementation (/sandbox/webpack.config.js:15:21)
at worker (/sandbox/node_modules/image-minimizer-webpack-plugin/dist/worker.js:83:47)
at Object.loader (/sandbox/node_modules/image-minimizer-webpack-plugin/dist/loader.js:101:24)
@ ./src/index.js 1:0-28
Solution
For user
Using options.minimizer.filter
or options.loader = false
can aviod this error.
For Owner
image-minimizer-webpack-plugin/src/index.js
Line 341 in bfae225
Use data:image/*
instead data:*
I can send a PR.
But why allow data:*
in the first place?
Ideally you should ignore them in custom minimizer too, because your minimizer potentially can't support them too, anyway we should improve this, because we do a lot of unnecessary works and improve speed, I will fix it