Skip to content

Plugin for Lasso.js for minifying GIF, PNG, JPG and SVG images during optimization

Notifications You must be signed in to change notification settings

lasso-js/lasso-imagemin

Repository files navigation

lasso-imagemin

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

Installation

Install the plugin:

npm install lasso-imagemin --save

Enable the plugin:

require('lasso').configure({
    plugins: [
        {
            plugin: 'lasso-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('lasso').configure({
    plugins: [
        {
            plugin: 'lasso-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: {}
                    }
                ]
            }
        },
        ...
    ]
});

About

Plugin for Lasso.js for minifying GIF, PNG, JPG and SVG images during optimization

Resources

Stars

Watchers

Forks

Packages

No packages published