imagemin / imagemin-svgo

SVGO plugin for imagemin
MIT License
125 stars 28 forks source link

ERROR in minimizer function doesn't return the 'data' property or result is not a 'Buffer' value #65

Open myarmolinsky opened 3 months ago

myarmolinsky commented 3 months ago

What were you expecting to happen?

I expected to get the minimized .svg files.

What actually happened?

I get errors for each of my svg files: ERROR in minimizer function doesn't return the 'data' property or result is not a 'Buffer' value Note: I only see this in production mode, development mode doesn't show any errors

Please give us a sample of your webpack.config.js

...
const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin');
...
config = {
  ...
  optimization: {
    ...
    minimizer: [
      ...
      new ImageMinimizerPlugin({
    minimizer: {
      implementation: ImageMinimizerPlugin.imageminMinify,
      options: {
        // Lossless optimization with custom option
        plugins: [
          ['gifsicle', { interlaced: true }],
              ['jpegtran', { progressive: true }],
          ['optipng', { optimizationLevel: 5 }],
          // Svgo configuration here https://github.com/svg/svgo#configuration
          [
            'svgo',
            {
              plugins: [
            {
              name: 'preset-default',
              params: {
                overrides: {
                  removeViewBox: false,
                  addAttributesToSVGElement: {
                params: {
                  attributes: [{ xmlns: 'http://www.w3.org/2000/svg' }],
                },
                  },
                },
              },
            },
              ],
            },
          ],
        ],
      },
        },
      }),
      ...
    ]
    ...
  }
  ...
}

Terminal output / screenshots

The following is displayed for each svg file:

ERROR in ./src/img/usage.svg
Module Error (from ./node_modules/image-minimizer-webpack-plugin/dist/loader.js):
minimizer function doesn't return the 'data' property or result is not a 'Buffer' value
// there's also a stack trace after this ^ but it doesn't have anything about imagemin, only my codebase

After the above is displayed for each file, I see the following error repeated 24 times: ERROR in minimizer function doesn't return the 'data' property or result is not a 'Buffer' value

Please provide the following information:

OS & version: Windows 11 Pro version 22H2 build 22621.3737 node version (run node -v): 20.14.0 npm version (run npm -v): 10.7.0 Webpack version (run npx webpack -v): 5.91.0 imagemin version: 9.0.0 imagemin-svgo: 11.0.1