rspack
rspack copied to clipboard
support ImageMinimizerWebpackPlugin
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
we already supports https://www.npmjs.com/package/image-webpack-loader, so can use it as workaround
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"?
Bump
You can close it I managed to make it work with this: https://rspack.dev/guide/features/asset-module#using-optimizers-as-loaders
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.
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!
bump
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!
bump