JSPM

  • Created
  • Published
  • Downloads 29649
  • Score
    100M100P100Q147987F
  • License MIT

Webpack plugin to compress images

Package Exports

  • imagemin-webpack-plugin

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (imagemin-webpack-plugin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Imagemin plugin for Webpack

js-standard-style

This is a simple plugin that uses Imagemin to compress all images in your project.

Install

npm install imagemin-webpack-plugin

Usage

var ImageminPlugin = require('imagemin-webpack-plugin').default
// Or if using ES2015:
// import ImageminPlugin from 'imagemin-webpack-plugin'

module.exports = {
  plugins: [
    // Make sure that the plugin is after any plugins that add images
    // These are the default options:
    new ImageminPlugin({
      disable: false,
      optipng: {
        optimizationLevel: 3
      },
      gifsicle: {
        optimizationLevel: 1
      },
      jpegtran: {
        progressive: false
      },
      svgo: {
      },
      pngquant: null, // pngquant is not run unless you pass options here
      plugins: []
    })
  ]
}

Options

Includes the following imagemin plugins:

plugins

Provide any additional plugins you want to have Imagemin run, and their options. Ex:

{
  pngquant: {
    quality: '95-100'
  },
  plugins: [
    imageminMozjpeg({
      quality: 100
    })
  ]
}

disable

Pass disable: true to disable this plugin, like during development. Defaults to false.

FAQ

Why?
I was suprised that there weren't any Imagemin plugins for webpack, so I made one!

Why not use image-webpack-loader?
Because I had other things like the favicons-webpack-plugin and responsive-loader that were generating images that I couldn't have image-webpack-loader optimize. This plugin will optimize ANY images regardless of how they were added to webpack. Plus image-webpack-loader is currently using an older version of imagemin.

Can you add this new feature?
Maybe... I'm trying to keep this a small single-purpose plugin, but if you want a feature feel free to open an issue and I'll take a look.

Inspiration

Contributing

The code is written in ES6 using Javascript Standard Style. Feel free to make PRs adding features you want, but please try to follow Standard. Also, codumentation/readme PRs are more then welcome!

License

MIT Copyright (c) Gregory Benner