Closed loooping-old closed 5 years ago
Replace the ImageminPlugin part of your webpack config with this below:
new ImageminPlugin({
maxConcurrency: 1,
test: function (filename) {
console.log('Attempting to compress "' + filename + '"...')
return (/\.(jpe?g|png|gif|svg)$/i).test(filename)
}
})
When you run that, it should console.log each image that it is minifying as it minifies it. (it will take much longer because I set maxConcurrency
to 1, but that is just for this test)
Then can you post the image that it logs right before failing so I can see it?
If it's really just a corrupted JPEG image, then this plugin won't give you any easy way to stop that right now. I might be able to make a change that catches errors like that and just puts the original image through, but I won't have time to do that for a little bit. (if you are willing, I'd gladly accept a PR to this plugin that does that!)
You might also be able to use copy-webpack-plugin
's transform property to check that the JPEG is valid, and try to either fix or remove any broken/corrupted images before they get to this plugin.
In my build I had the error:
I noticed that the error only occurs in a folder that is more than 1GB
How to skip corrupted files?
My Webpack config: