pngmin-webpack-plugin

Webpack plugin to compress PNG

Usage no npm install needed!

<script type="module">
  import pngminWebpackPlugin from 'https://cdn.skypack.dev/pngmin-webpack-plugin';
</script>

README

Imagemin plugin for Webpack

npm js-standard-style npm donate

This is a simple plugin that uses Pngmin to compress PNG in your project.

Install

npm install pngmin-webpack-plugin

Requires node >=4.0.0

Example Usage

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

module.exports = {
  plugins: [
    // Make sure that the plugin is after any plugins that add images
    new PngminPlugin({
      pngquant: {
        quality: '95-100'
      }
    })
  ]
}

Working with copy-webpack-plugin:

module.exports = {
  plugins: [
    // Copy the images folder and optimize all the images
    new CopyWebpackPlugin([{
      from: 'images/'
    }]),
    new PngminPlugin({
      pngquant: {
        quality: '95-100'
      }
    })
  ]
}

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