Gulp imagemin prints error because it affects not only .png files

406 views Asked by At

Gulp imagemin prints error because it affects .svg files along with .png images.

The error is:

[19:37:49] gulp-imagemin: Minified 0 images
events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: Unsupported file type: image/svg+xml
    at doParse (C:\Users\ndruce\Desktop\Проекты\revton\node_modules\get-pixels\node-pixels.js:126:10)
    at getPixels (C:\Users\ndruce\Desktop\Проекты\revton\node_modules\get-pixels\node-pixels.js:140:5)
    at handleFileBuffer (C:\Users\ndruce\Desktop\Проекты\revton\node_modules\pixelsmith\lib\engine.js:45:13)
    at ConcatStream.<anonymous> (C:\Users\ndruce\Desktop\Проекты\revton\node_modules\pixelsmith\node_modules\concat-stream\index.js:36:43)
    at ConcatStream.emit (events.js:182:13)
    at finishMaybe (C:\Users\ndruce\Desktop\Проекты\revton\node_modules\pixelsmith\node_modules\readable-stream\lib\_stream_writable.js:475:14)
    at afterWrite (C:\Users\ndruce\Desktop\Проекты\revton\node_modules\pixelsmith\node_modules\readable-stream\lib\_stream_writable.js:361:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)
Emitted 'error' event at:
    at done (C:\Users\ndruce\Desktop\Проекты\revton\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:202:25)
    at C:\Users\ndruce\Desktop\Проекты\revton\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:139:7
    at handleImages (C:\Users\ndruce\Desktop\Проекты\revton\node_modules\gulp.spritesmith\lib\gulp-spritesmith.js:196:16)
    at C:\Users\ndruce\Desktop\Проекты\revton\node_modules\gulp.spritesmith\node_modules\async\dist\async.js:3694:9
    at C:\Users\ndruce\Desktop\Проекты\revton\node_modules\gulp.spritesmith\node_modules\async\dist\async.js:359:16
    at iteratorCallback (C:\Users\ndruce\Desktop\Проекты\revton\node_modules\gulp.spritesmith\node_modules\async\dist\async.js:933:13)
    at C:\Users\ndruce\Desktop\Проекты\revton\node_modules\gulp.spritesmith\node_modules\async\dist\async.js:843:16
    at C:\Users\ndruce\Desktop\Проекты\revton\node_modules\gulp.spritesmith\node_modules\async\dist\async.js:3691:13
    at apply (C:\Users\ndruce\Desktop\Проекты\revton\node_modules\gulp.spritesmith\node_modules\async\dist\async.js:21:25)
    at C:\Users\ndruce\Desktop\Проекты\revton\node_modules\gulp.spritesmith\node_modules\async\dist\async.js:56:12

Gulp part of code:

gulp.task('img:build', function () {
    gulp.src('src/img/**/*.{png}')
        .pipe(plumber())
        .pipe(imagemin({
            progressive: true,
            svgoPlugins: [{removeViewBox: false}],
            use: [pngquant()],
            interlaced: true
        }))
        .pipe(gulp.dest(path.build.img))
        .pipe(reload({stream: true}));
});

What is the solution for this problem? I just want to recursively optimize .png images.

0

There are 0 answers