Image minimizing loader for webpack 4, version 4.0.0. It relies on imagemin and its plugins to optimize PNG, JPEG, GIF, and SVG images. The loader is intended for use with webpack 4 and requires Node >=12. It differs from alternatives like image-webpack-loader by being a thin wrapper that delegates all optimization to user-specified imagemin plugins, offering flexibility but requiring manual plugin installation and configuration.
npm install img-loaderVerified import paths — ran on the pinned version, not inferred.
Shows a minimal webpack 4 configuration using img-loader with url-loader and three imagemin plugins (mozjpeg, pngquant, svgo) for image optimization.
Install desired imagemin plugins (e.g., imagemin-gifsicle, imagemin-mozjpeg, imagemin-optipng, imagemin-svgo) and configure them in the 'plugins' option.
Use image-webpack-loader or other webpack 5-compatible image optimizers for webpack 5 projects.
Run `npm install imagemin --save-dev` alongside img-loader.
Define at least one imagemin plugin in the 'plugins' option for actual compression.
Call the plugin function with an options object: require('imagemin-mozjpeg')({ progressive: true })npm install imagemin --save-dev
Ensure 'plugins' is an array of instantiated imagemin plugins, like [require('imagemin-mozjpeg')({})]Ensure the function returns an array and uses the provided context parameter correctly.