optimizer-imagemin

1.0.5 • Public • Published

optimizer-imagemin

This plugin for the RaptorJS Optimizer allows the imagemin module to be used to minify GIF, PNG, JPG and SVG images during optimization.

Installation

Install the plugin:

npm install optimizer-imagemin --save

Enable the plugin:

require('optimizer').configure({
    plugins: [
        {
            plugin: 'optimizer-imagemin',
            config: {
                ... // See below for config options
            }
        },
        ...
    ]
});

Plugin Configuration

This plugins supports the following builtin image minification plugins:

  • gifsicle — Compress GIF images.
  • jpegtran — Compress JPG images.
  • optipng — Lossless compression of PNG images.
  • pngquant — Lossy compression of PNG images.
  • svgo — Compress SVG images.

The full list of plugins can found on the following page: imagemin plugins

If you intend to use a non-builtin plugin then you must npm install it first (e.g. npm install imagemin-webp).

Sample Configuration

require('optimizer').configure({
    plugins: [
        {
            plugin: 'optimizer-imagemin',
            config: {
                use: [
                    {
                        paths: ['**/*.gif'],
                        plugin: 'gifsicle',
                        options: { interlaced: true }
                    },
                    {
                        paths: ['**/*.png'],
                        plugin: 'optipng',
                        options: { optimizationLevel: 3 }
                    },
                    {
                        // Non-builtin plugins must be referenced by npm module name:
                        paths: ['**/*.webp'],
                        plugin: 'imagemin-webp', // Or: require('imagemin-webp')
                        options: {}
                    }
                ]
            }
        },
        ...
    ]
});

Package Sidebar

Install

npm i optimizer-imagemin

Weekly Downloads

0

Version

1.0.5

License

Apache License v2.0

Last publish

Collaborators

  • austinkelleher
  • dylanpiercey
  • mlrawlings
  • pnidem