Skip to content

Optimize images with global caching and convert of non-transparent png to jpg (on the fly)

Notifications You must be signed in to change notification settings

glebmachine/image-optimize-loader

Repository files navigation

image-optimize-loader Build Status npm version

Optimize images with global caching and convert of non-transparent png to jpg (on the fly)

Rework of https://github.com/tcoopman/image-webpack-loader

Features

  • Opmitize images with pngquant/mozjpeg/svgo (like image-webpack-loader)
  • Cache results into your OS tmp folder

Webpack 2.0 features

  • Convert non-transparent png images into jpg (due up to 7x size reduction)

Install

$ npm install image-optimize-loader --save-dev

Usage

loaders: [
    {
        test: /\.(jpe?g|png|gif|svg)$/i,
        loaders: [
            'file?hash=sha512&digest=hex&name=[hash].[ext]',
            'image-optimize'
        ]
    }
]

Configuration

{ // default configuration example
  imageOptimizeLoader: {
    optimizer: {
      covertPngToJpg:true
    },
    pngquant: {
      quality: '65-80',
      speed: 4
    },
    mozjpeg:{
      targa: false,
    },
    svgo: {
      plugins:[
        { removeComments: true },
        { sortAttrs: true },
        { minifyStyles: true },
      ]
    }
}

License

MIT (http://www.opensource.org/licenses/mit-license.php)

About

Optimize images with global caching and convert of non-transparent png to jpg (on the fly)

Resources

Stars

Watchers

Forks

Packages

No packages published