const config = protoss.config.images;
const plumber = require('gulp-plumber');
const imagemin = require('gulp-imagemin');

module.exports = function(options) {

  return function(cb) {

    if (!protoss.flags.isDev) return cb(null);

    protoss.gulp.src(config.dest + '**/*.{png,jpg,gif,svg}')

      // Prevent pipe breaking
      .pipe(plumber(function(error) {
        protoss.notifier.error('An error occurred while optimizing images: ' + error);
        this.emit('end');
      }))

      // Minify images
      .pipe(imagemin({
        svgoPlugins: [
          { cleanupIDs: false },
          { removeViewBox: false },
          { convertPathData: false },
          { mergePaths: false },
          {removeXMLProcInst: false }
        ]
      }))

      // Save optimized images
      .pipe(protoss.gulp.dest(config.dest))

      .on('end', function() {

        protoss.notifier.success('Images optimized');

        if (protoss.flags.isWatching)
          protoss.browserSync.reload();

        cb(null); // End task

      });

  };

};

@@ -526,17 +526,17 @@
 magemin(
-%7B
+%5B
 %0A       
@@ -540,23 +540,89 @@
     
-svgoPlugins: %5B%0A
+imagemin.svgo(%7B%0A          plugins: %5B%0A            %7B removeUselessDefs: false %7D,%0A  
     
@@ -642,32 +642,34 @@
 upIDs: false %7D,%0A
+  
           %7B remo
@@ -698,16 +698,18 @@
         
+  
 %7B conver
@@ -738,16 +738,18 @@
         
+ 
+ 
 %7B mergeP
@@ -755,32 +755,34 @@
 Paths: false %7D,%0A
+  
           %7Bremov
@@ -776,16 +776,17 @@
        %7B
+ 
 removeXM
@@ -804,16 +804,18 @@
 false %7D%0A
+  
         
@@ -818,25 +818,36 @@
     %5D%0A      
-%7D
+  %7D)%0A      %5D
 ))%0A%0A      //

fix imagemin config