imgmin-loader
A loader for webpack4 which minify images.
Getting Started
To begin, you'll need to install imgmin-loader
:
$ npm install imgmin-loader imagemin-pngquant imagemin-mozjpeg --save-dev
webpack.config.js
moduleexports = module: rules: test: /\.$/i use: loader: 'url-loader' options: limit: 8192 loader: 'imgmin-loader' options: limit: 8192 plugins:
And run webpack
via your preferred method.
Options
limit
Type: Number|Boolean|String
Default: undefined
The limit can be specified via loader options and defaults to no limit.
Number
A Number
specifying the maximum size of an image in bytes. If the image size is
equal or greater than the limit, will disable minify.
webpack.config.js
moduleexports = module: rules: test: /\.$/i use: loader: 'imgmin-loader' options: limit: 8192 plugins:
Boolean
Enable or disable minify images.
webpack.config.js
moduleexports = module: rules: test: /\.$/i use: loader: 'imgmin-loader' options: limit: false plugins: