Using alternative minimizer with bud-imagemin

I need to upgrade to node 18, but I can’t, because of bud-imagemin that requires googlechromelabs/squoosh, itself requiring node 16.

Is there a way to force bud-imagemin to use another minimizer ?

Alternatively how can I configure wepback minimizer setting with bud, so that i can setup imagemin myself without using bud-imagemin ?

I got it working following webpack docs. Here is my config:

yarn add -D image-minimizer-webpack-plugin imagemin imagemin-gifsicle imagemin-jpegtran imagemin-optipng imagemin-svgo
import ImageMinimizerPlugin from 'image-minimizer-webpack-plugin';

//...
app.config((config) => {
    config.optimization.minimizer.push(
      new ImageMinimizerPlugin({
        minimizer: {
          implementation: ImageMinimizerPlugin.imageminMinify,
          options: {
            plugins: [
              ['gifsicle', {interlaced: true}],
              ['jpegtran', {progressive: true}],
              ['optipng', {optimizationLevel: 5}],
              [
                'svgo',
                {
                  plugins: [
                    {
                      name: 'preset-default',
                      params: {
                        overrides: {
                          removeViewBox: false,
                          addAttributesToSVGElement: {
                            params: {
                              attributes: [
                                {xmlns: 'http://www.w3.org/2000/svg'},
                              ],
                            },
                          },
                        },
                      },
                    },
                  ],
                },
              ],
            ],
          },
        },
      }),
    );
    return config;
  });

Wondering if I can get something cleaner using only bud-imagemin :thinking:

2 Likes