Imagemin loader module for webpack
Switch branches/tags
greenkeeper/ajv-6.5.4 greenkeeper/ajv-6.5.5 greenkeeper/ajv-6.6.0 greenkeeper/ajv-6.6.1 greenkeeper/ajv-pin-6.5.3 greenkeeper/commitizen-3.0.0 greenkeeper/commitizen-3.0.1 greenkeeper/commitizen-3.0.2 greenkeeper/commitizen-3.0.3 greenkeeper/commitizen-3.0.4 greenkeeper/commitizen-3.0.5 greenkeeper/imagemin-mozjpeg-8.0.0 greenkeeper/initial greenkeeper/mocha-pin-3.3.0 greenkeeper/prettier-1.14.3 greenkeeper/prettier-1.15.0 greenkeeper/prettier-1.15.1 greenkeeper/prettier-1.15.2 greenkeeper/prettier-1.15.3 greenkeeper/prettier-pin-1.14.2 greenkeeper/semantic-release-15.9.15 greenkeeper/semantic-release-15.9.16 greenkeeper/semantic-release-15.9.17 greenkeeper/semantic-release-15.10.3 greenkeeper/semantic-release-15.10.4 greenkeeper/semantic-release-15.10.5 greenkeeper/semantic-release-15.10.6 greenkeeper/semantic-release-15.10.7 greenkeeper/semantic-release-15.10.8 greenkeeper/semantic-release-15.11.0 greenkeeper/semantic-release-15.12.0 greenkeeper/semantic-release-15.12.1 greenkeeper/semantic-release-15.12.2 greenkeeper/semantic-release-15.12.3 greenkeeper/semantic-release-15.12.4 greenkeeper/semantic-release-15.12.5 greenkeeper/semantic-release-pin-15.9.14 greenkeeper/@types/node-10.10.0 greenkeeper/@types/node-10.10.1 greenkeeper/@types/node-10.10.2 greenkeeper/@types/node-10.10.3 greenkeeper/@types/node-10.11.0 greenkeeper/@types/node-10.11.1 greenkeeper/@types/node-10.11.2 greenkeeper/@types/node-10.11.3 greenkeeper/@types/node-10.11.4 greenkeeper/@types/node-10.11.5 greenkeeper/@types/node-10.11.6 greenkeeper/@types/node-10.11.7 greenkeeper/@types/node-10.12.0 greenkeeper/@types/node-10.12.1 greenkeeper/@types/node-10.12.2 greenkeeper/@types/node-10.12.3 greenkeeper/@types/node-10.12.4 greenkeeper/@types/node-10.12.5 greenkeeper/@types/node-10.12.6 greenkeeper/@types/node-10.12.7 greenkeeper/@types/node-10.12.8 greenkeeper/@types/node-10.12.9 greenkeeper/@types/node-10.12.10 greenkeeper/@types/node-10.12.11 greenkeeper/@types/node-10.12.12 greenkeeper/@types/node-10.12.13 greenkeeper/@types/node-10.12.14 greenkeeper/@types/node-10.12.15 greenkeeper/@types/node-pin-10.9.4 master
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
schema
source
test
.gitignore
.npmrc
.prettierrc
.travis.yml
LICENSE
README.md
package-lock.json
package.json
tsconfig.json

README.md

imagemin-loader

Build Status npm version npm downloads dependencies greenkeeper styled with prettier semantic-release Commitizen friendly

Imagemin hook for webpack 3

Minify all images seamlessly with imagemin

Oh. but Why?

Because none of the other loaders out there would allow me to use my own imagemin plugin.

Install

$ npm install imagemin-loader -D

Usage

In your webpack.config.js add the imagemin-loader, chained with the file-loader, url-loader or raw-loader:

module: {
    rules: [
        {
            test: /\.(png|jpe?g|gif|svg)$/,
            use: [
                
                /** file-loader | url-loader | raw-loader **/
                { loader: 'file-loader' },
                
                {
                    loader: 'imagemin-loader',
                    options: {
                        // enabled: process.env.NODE_ENV === 'production',
                        plugins: [
                            {
                                use: 'imagemin-pngquant',
                                options: {
                                    quality: '50-60'
                                }
                            },
                            {
                                /** Alternative syntax **/
                                use: require('imagemin-guetzli'),
                                options: {
                                    enabled: process.env.NODE_ENV === 'production',
                                    quality: 95
                                }
                            }
                        ]
                    }
                }
            ]
        }
    ]
}

You can use any imagemin plugin, simple include it on the plugin array and install it as a local dependency.

Options

{
    enabled: boolean, // Enable or disable the loader globally
    plugins: [
        {
            use: string|function, // Package name like: 'imagemin-gifsicle', require('imagemin-gifsicle') or a Function
            options: {
                enabled: boolean, // Enable or disable at the plugin level
                ...ImageMinPluginOptions // Specific plugin options
            }
        }
    ]
}

License

MIT © Rafael Milewski