image-minimizer-webpack-plugin icon indicating copy to clipboard operation
image-minimizer-webpack-plugin copied to clipboard

Documentation: Typo in the squoosh-generator-resize section

Open drinking-code opened this issue 3 years ago • 2 comments

Documentation Is:

  • [ ] Missing
  • [ ] Needed
  • [x] Confusing
  • [ ] Not Sure?

Please Explain in Detail...

The documentation for the resize option of the squoosh generator has a typo:

const ImageMinimizerPlugin = require("image-minimizer-webpack-plugin");
module.exports = {
  optimization: {
    minimizer: [
      "...",
      new ImageMinimizerPlugin({
        generator: [
          {
            // You can apply generator using `?as=webp-100-50`, you can use any name and provide more options
            preset: "webp-100-50",
            implementation: ImageMinimizerPlugin.squooshGenerate,
            options: {
              encodeOptions: {
                resize: {
                  enabled: true,
                  width: 100,
                  height: 50,
                },
                webp: {
                  quality: 90,
                },
              },
            },
          },
        ],
      }),
    ],
  },
};

Your Proposal for Changes

Notice that the resize option is inside the encodeOptions, but it should actually say:

const ImageMinimizerPlugin = require("image-minimizer-webpack-plugin");
module.exports = {
  optimization: {
    minimizer: [
      "...",
      new ImageMinimizerPlugin({
        generator: [
          {
            // You can apply generator using `?as=webp-100-50`, you can use any name and provide more options
            preset: "webp-100-50",
            implementation: ImageMinimizerPlugin.squooshGenerate,
            options: {
              resize: {
                enabled: true,
                width: 100,
                height: 50,
              },
              encodeOptions: {
                webp: {
                  quality: 90,
                },
              },
            },
          },
        ],
      }),
    ],
  },
};

because utils.js takes the preprocess options for libsquoosh directly from squooshOptions (minifyOptions) and not from squooshOptions.encodeOptions

drinking-code avatar Mar 20 '22 14:03 drinking-code

PR welcome

alexander-akait avatar Mar 20 '22 14:03 alexander-akait

maybe a good first issue?

drinking-code avatar Mar 20 '22 16:03 drinking-code