@@ -9,14 +9,20 @@ const plur = require('plur');
99
1010const defaultPlugins = [ 'gifsicle' , 'jpegtran' , 'optipng' , 'svgo' ] ;
1111
12- const loadPlugin = plugin => {
12+ const loadPlugin = ( plugin , args ) => {
1313 try {
14- return require ( `imagemin-${ plugin } ` ) ( ) ; // eslint-disable-line import/no-dynamic-require
14+ return require ( `imagemin-${ plugin } ` ) . apply ( null , args ) ; // eslint-disable-line import/no-dynamic-require
1515 } catch ( err ) {
1616 gutil . log ( `gulp-imagemin: Couldn't load default plugin "${ plugin } "` ) ;
1717 }
1818} ;
1919
20+ const exposePlugin = plugin =>
21+ function ( ) {
22+ const args = [ ] . slice . call ( arguments ) ;
23+ return loadPlugin ( plugin , args ) ;
24+ } ;
25+
2026const getDefaultPlugins = ( ) =>
2127 defaultPlugins . reduce ( ( plugins , plugin ) => {
2228 const instance = loadPlugin ( plugin ) ;
@@ -104,7 +110,7 @@ module.exports = (plugins, opts) => {
104110 } ) ;
105111} ;
106112
107- module . exports . gifsicle = ( ) => loadPlugin ( 'gifsicle' ) ;
108- module . exports . jpegtran = ( ) => loadPlugin ( 'jpegtran' ) ;
109- module . exports . optipng = ( ) => loadPlugin ( 'optipng' ) ;
110- module . exports . svgo = ( ) => loadPlugin ( 'svgo' ) ;
113+ module . exports . gifsicle = exposePlugin ( 'gifsicle' ) ;
114+ module . exports . jpegtran = exposePlugin ( 'jpegtran' ) ;
115+ module . exports . optipng = exposePlugin ( 'optipng' ) ;
116+ module . exports . svgo = exposePlugin ( 'svgo' ) ;
0 commit comments