rspack icon indicating copy to clipboard operation
rspack copied to clipboard

support ImageMinimizerWebpackPlugin

Open jerrykingxyz opened this issue 2 years ago • 9 comments

What problem does this feature solve?

Supports all hooks used by ImageMinimizerWebpackPlugin. https://github.com/webpack-contrib/image-minimizer-webpack-plugin

Here is the list of unsupported hooks

compilation.hooks.moduleAsset
compilation.hooks.assetPath
compilation.hooks.afterSeal
compilation.hooks.statsPrinter
stats.hooks.print

jerrykingxyz avatar Apr 20 '23 08:04 jerrykingxyz

we already supports https://www.npmjs.com/package/image-webpack-loader, so can use it as workaround

hardfist avatar Apr 25 '23 03:04 hardfist

image-webpack-loader uses imagemin

but image-minimizer-webpack-plugin can be used with sharp and svgo

surely this should be "closed this as completed"?

dartess avatar Dec 04 '23 14:12 dartess

Bump

OreQr avatar Dec 08 '24 00:12 OreQr

You can close it I managed to make it work with this: https://rspack.dev/guide/features/asset-module#using-optimizers-as-loaders

OreQr avatar Dec 08 '24 14:12 OreQr

it work with this

Yes, but loader will only process those images that were imported. The plugin also processed those images that were simply copied by the HtmlWebpackPlugin plugin.

Therefore, in rspack, it was necessary to additionally manually configure optimization via transform in CopyRspackPlugin, like this:

transform: (input, absoluteFilename) => {
  if (absoluteFilename.includes('/affiliate/')) {
    return input;
  }
  switch (path.extname(absoluteFilename)) {
    case '.svg':
      return R.pipe(
        input.toString('utf-8'),
        content => svgo.optimize(content, svgoConfig),
        R.prop('data'),
      );
    case '.png':
      return sharp(input).png(sharpPngOptions).toBuffer();
    default:
      return input;
  }
},

So in an ideal world it would still be great to have support for image-minimizer-webpack-plugin as a plugin rather than as a loader.

dartess avatar Dec 09 '24 07:12 dartess

This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

stale[bot] avatar Feb 07 '25 07:02 stale[bot]

bump

dartess avatar Feb 07 '25 09:02 dartess

This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

stale[bot] avatar Apr 08 '25 09:04 stale[bot]

bump

dartess avatar Apr 08 '25 12:04 dartess