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

Commit

Permalink
Merge pull request #156 from Eterion/master
Browse files Browse the repository at this point in the history
Disable option (alternative to bypassOnDebug)
  • Loading branch information
tcoopman committed May 31, 2018
2 parents 84f3122 + ea8107f commit f864e8a
Show file tree
Hide file tree
Showing 4 changed files with 7,666 additions and 8 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading

0 comments on commit f864e8a

Please sign in to comment.