tcoopman / image-webpack-loader

Image loader module for webpack
MIT License
2.03k stars 131 forks source link

Possible to use other plugins? (imagemin-guetzli etc.) #85

Open lostpebble opened 7 years ago

lostpebble commented 7 years ago

I'd like to make use of the new JPEG compression from Google, https://github.com/google/guetzli/

I see there is an imagemin plugin for it: https://github.com/imagemin/imagemin-guetzli

I've downloaded it and tried to use it by just adding some options to it in the query:

{
        test: /\.(jpe?g|png|gif|svg)$/i,
        loaders: ['file-loader?context=src/images&name=images/[path][name].[ext]', {
          loader: 'image-webpack-loader',
          query: {
            guetzli: {
              quality: 95,
            },
            gifsicle: {
              interlaced: false,
            },
            optipng: {
              optimizationLevel: 4,
            },
            pngquant: {
              quality: '75-90',
              speed: 3,
            },
          },
        }],
        exclude: /node_modules/,
        include: __dirname,
      },

But this doesn't seem to work. I think it would be cool if we could easily add plugins like this. Or perhaps I'm missing the right way to do it?

milewski commented 7 years ago

Yeah it would be quite easy to add a new plugin into this lib. but probably would be more ideal if we could pass our own optimizers manually

milewski commented 7 years ago

Well i just added it myself with this pull request https://github.com/tcoopman/image-webpack-loader/pull/86

But keep in mind that this new google jpg compressor consomes a looooooooooooooooot of CPU and memory.. i mean ... really a lot.. my 32gb memory machine wasn't able to compile the project i am currently working on in time... it took like 20 minutes to compile.... god.. this is not viable in development.. and probably nor even in production O.O

scorgn commented 6 years ago

Has this been resolved? Not specific to imagemin-guetzli, are we able to somehow pass in other imagemin plugins?

milewski commented 6 years ago

@ShawnCorrigan https://github.com/milewski/imagemin-loader i made a version that u can pass any plugin manually

scorgn commented 6 years ago

@milewski Ah thanks, I made a PR with the ability to pass any plugin, but I guess it's not likely to be accepted.

milewski commented 6 years ago

i did that too.. https://github.com/tcoopman/image-webpack-loader/pull/86 but never got a response