Coder Social home page Coder Social logo

Comments (7)

alexander-akait avatar alexander-akait commented on July 17, 2024 2

Please update https://github.com/webpack-contrib/image-minimizer-webpack-plugin/releases/tag/v4.0.2 and use configuration above, feel free to feedback

from image-minimizer-webpack-plugin.

redRusUnstpbl avatar redRusUnstpbl commented on July 17, 2024 1

@alexander-akait you can check my rep for investigation, I tried different options, but the error is always the same. Its clear project with only react, typescript and some loaders, without extra plugins.

https://github.com/redRusUnstpbl/sv_st1/

from image-minimizer-webpack-plugin.

alexander-akait avatar alexander-akait commented on July 17, 2024 1

Found a problem, bug in imageminSvgo:

in imagemin-svgo, they expected it should be buffer or string

if (!isSvg(buffer)) {
  return buffer;
}

But in is-svg:

if (typeof string !== 'string') {
  throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
}

So imagemin-svgo accepts string | Buffer, but is-svgo only string

weird, WIP on this

from image-minimizer-webpack-plugin.

redRusUnstpbl avatar redRusUnstpbl commented on July 17, 2024 1

@alexander-akait It work now, thx )

from image-minimizer-webpack-plugin.

alexander-akait avatar alexander-akait commented on July 17, 2024

Hm, looks like something wrong with options, because imagemin doesn't validate them

from image-minimizer-webpack-plugin.

alexander-akait avatar alexander-akait commented on July 17, 2024

Investigate

from image-minimizer-webpack-plugin.

alexander-akait avatar alexander-akait commented on July 17, 2024

Okay, looks like imagemin-svgo is not compatibility with imagemin@9, but it is not a problem - let's use it directly, I will fix our docs, so after #444 merged (I want to do it today), please use this configuration:

new ImageMinimizerPlugin({
  minimizer: [
    {
      implementation: ImageMinimizerPlugin.imageminMinify,
      options: {
        // 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 }],
        ],
      },
    },
    {
      implementation: ImageMinimizerPlugin.svgoMinify,
      options: {
        encodeOptions: {
          // Pass over SVGs multiple times to ensure all optimizations are applied. False by default
          multipass: true,
          plugins: [
            {
              name: "preset-default",
              params: {
                overrides: {
                  removeViewBox: false,
                  addAttributesToSVGElement: {
                    params: {
                      attributes: [{ xmlns: "http://www.w3.org/2000/svg" }],
                    },
                  },
                },
              },
            },
          ],
        },
      },
    },
  ],
});

There is an issue with imagemin-svgo - imagemin/imagemin-svgo#62, you faced with it, but I can't fix it here

from image-minimizer-webpack-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.