webpack-图片压缩优化-image-webpack-loader

下载

cnpm install --save-dev image-webpack-loader

cli 3和4 用法 (测试 比正常cli压缩图片少个几百kb左右吧)

chainWebpack: config => {
    config.module
      .rule('images')
      .use('image-webpack-loader')
      .loader('image-webpack-loader')
      .options({
        mozjpeg: {
          progressive: true,
          quality: 50
        },
        optipng: {
          enabled: true
        },
        pngquant: {
          quality: [0.5, 0.65],
          speed: 4
        },
        gifsicle: {
          interlaced: false
        }
      })
      .end()
  },

你可能感兴趣的:(webpack-图片压缩优化-image-webpack-loader)