image-minimizer-webpack-plugin: Support for processing images using CopyWebpackPlugin doesn't work in v3

Hi – I’m trying to upgrade to v3, but I can’t seem to get the new version to work in concert with the CopyWebpackPlugin.

Basically I’m moving a bunch of pngs into a specific folder and then am converting them to webp.

Here is my current webpack config if that helps any: https://github.dev/gitkraken/vscode-gitlens/blob/15e4f478c3e84c78552c7531dbbbaa926c91ed35/webpack.config.js#L379-L398

Here is a discussion about the prior support: https://github.com/webpack/webpack/discussions/14280#discussioncomment-1851786

Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 33 (22 by maintainers)

Commits related to this issue

Most upvoted comments

Woo! Works – thanks so much!

I will look at this in near future

Odd, happened every time with the yarn run watch build.

Ah gotcha – thanks for the clarification. And thanks so much for the investigation and fix! Even if the perf is worse, I’ll be happy to switch over to squoosh over imagemin as the later is now unmaintained.

Thanks again!

@eamodio Fixed https://github.com/webpack-contrib/image-minimizer-webpack-plugin/pull/293, works with with your examples, unfortunately it is slow than imagemin (and the problem in squoosh, that is strange, because squoosh create worker only once, imagemin do it on each call), my first idea - the problem in double buffer converting, investigating it too

Found leaking… wip on fix

@alexander-akait Thank you!

So I tried it out both integrated with my GitLens build and also as a completely separate webpack config (for debugging). and even with the latest I still see the memory errors when integrated into the GitLens build, but not when it’s part of its own config.

While not a simple sample, if you clone https://github.com/gitkraken/vscode-gitlens, and yarn install you can try the multiple versions.

These configs cause issue when using squoosh (here is the config): yarn run build — will build everything using ImageMinimizerPlugin as a plugin using image-min yarn run build --env squoosh — same as above but will use squoosh and fail with wasm out of memory errors yarn run bundle — will build everything using ImageMinimizerPlugin as an optimizer using image-min yarn run bundle --env squoosh — same as above but will use squoosh and fail with wasm out of memory errors

These configs work fine with squoosh (here is the config): yarn run copy:images — will use ImageMinimizerPlugin as a plugin using image-min yarn run copy:images --env squoosh — same as above but will use squoosh yarn run copy:images --mode production — will use ImageMinimizerPlugin as an optimizer using image-min yarn run copy:images --mode production --env squoosh — same as above but will use squoosh

@alexander-akait Thanks will check that out!

[EDIT] I’ve switched over now thanks! 😄