Klathmon / imagemin-webpack-plugin

Plugin to compress images with imagemin
MIT License
683 stars 53 forks source link

does not work for webp #94

Closed psabharwal123 closed 5 years ago

psabharwal123 commented 5 years ago

I tried the following -

    config.plugins.push(new ImageminPlugin({
        svgo: null,
        jpegtran: {
            progressive: true
        },
        plugins: [
            imageminWebp({
                quality: 75
            })
        ]
    }));

however it is not generating webp images for the jpeg and png. is it only for compressing existing webp images?

Klathmon commented 5 years ago

I'm not familiar with the imageminWebp plugin, does it normally convert the images from jpeg and png to webp?

This plugin is really only a framework/scaffolding to allow running the imagemin plugins in a webpack pipeline, so it's up to the restrictions of how webpack can show images to imagemin, and how the imagemin plugins handle and output those files.

At this point, it is setup to pass the image data to the plugin, then take whatever the plugin returns and write it to a filename of the same name in the output. So even if imageminWebp did convert the image to a webp, it will still save as a jpeg or png.

You'll probably want to either use another plugin for that use case to convert the images first then have this one optimize them, or use another plugin/loader that can do both in one.