在 image-minimizer-webpack-plugin (mozjpeg, pngquant) 中使用有损模块时出错

问题描述

我这个配置有问题吗?我是否期望将 image-minimizer-webpack-plugin 用作单个步骤,编译整个项目模块不正确?

此配置会导致所有经过测试的图像资产文件出现以下错误。图像文件仍然被压缩和发射;但是我不希望出现错误

ERROR in Conflict: Multiple assets emit different content to the same filename ./imgs/[...]

    new ImageminimizerPlugin({
      test: /\.(png|jpe?g)$/i,deleteOriginalAssets: true,minimizerOptions: {
        plugins: [
          ['mozjpeg',{ quality: 75 }],['pngquant',{ speed: 10,quality: [0.3,0.5] }],],},}),
      {
        test: /\.(png|jpe?g)$/i,type: 'asset/resource',generator: {
          filename: './imgs/[base]'
        },
    new ImageminimizerPlugin({
      minimizerOptions: {
        // Lossless optimization with custom option
        // Feel free to experiment with options for better result for you
        plugins: [
          ['gifsicle',{ interlaced: true }],['jpegtran',{ progressive: true }],['optipng',{ optimizationLevel: 5 }],[
            'svgo',{
              plugins: [
                {
                  removeViewBox: false,

上述无损配置不会导致此类错误

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)