Skip to content
This repository has been archived by the owner on Mar 17, 2023. It is now read-only.

Commit

Permalink
Disable option for webpack@2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Eterion committed May 31, 2018
1 parent 4dcac71 commit e424808
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion README.md
Expand Up @@ -41,7 +41,8 @@ rules: [{
{
loader: 'image-webpack-loader',
options: {
bypassOnDebug: true,
bypassOnDebug: true, // webpack@1.x
disable: true, // webpack@2.x and newer
},
},
],
Expand Down Expand Up @@ -110,6 +111,13 @@ Default: `false`

Using this, no processing is done when webpack 'debug' mode is used and the loader acts as a regular file-loader. Use this to speed up initial and, to a lesser extent, subsequent compilations while developing or using webpack-dev-server. Normal builds are processed normally, outputting optimized files.

#### disable

Type: `boolean`
Default `false`

Same functionality as **bypassOnDebug** option, but doesn't depend on webpack debug mode, which was deprecated in 2.x. Basically you want to use this option if you're running webpack@2.x or newer.

For optimizer options, an up-to-date and exhaustive list is available on each optimizer repository:

- [mozjpeg](https://github.com/imagemin/imagemin-mozjpeg#options)
Expand Down
3 changes: 2 additions & 1 deletion index.js
Expand Up @@ -29,6 +29,7 @@ module.exports = function(content) {

var options = {
bypassOnDebug: config.bypassOnDebug || false,
disable: config.disable || false,
// default optimizers
gifsicle: config.gifsicle || {},
mozjpeg: config.mozjpeg || {},
Expand All @@ -55,7 +56,7 @@ module.exports = function(content) {
var callback = this.async(),
called = false;

if (this.debug === true && options.bypassOnDebug === true) {
if ((this.debug === true && options.bypassOnDebug === true) || options.disable === true) {
// Bypass processing while on watch mode
return callback(null, content);
} else {
Expand Down

0 comments on commit e424808

Please sign in to comment.