Gulp imagemin 会打印错误,因为它会影响.svg
文件和.png
图像。
错误是:
[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 部分代码:
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}));
});
这个问题的解决方案是什么?我只想递归优化.png
图像。