项目里引用了gulp-imagemin这个task, task运行正常没有报错,但是在dist目录中发现图片并没有被压缩。
gulp.task('images', () => {
return gulp.src('app/images/**/*')
.pipe($.if($.if.isFile, $.cache($.imagemin({ //使用"gulp-cache"只压缩修改的图片
optimizationLevel: 5, //类型:Number 默认:3 取值范围:0-7(优化等级)
progressive: true, //类型:Boolean 默认:false 无损压缩jpg图片
interlaced: true,
// don't remove IDs from SVGs, they are often used
// as hooks for embedding and styling
svgoPlugins: [{ cleanupIDs: false }],
use: [pngquant()] //使用pngquant深度压缩png图片
}))
.on('error', function(err) {
console.log(err);
this.end();
})))
.pipe($.rev())
.pipe(gulp.dest('dist/images'))
.pipe($.rev.manifest())
.pipe(gulp.dest('dist/rev/images'))
});
请大神帮忙看看我这个task有没有问题。
直接写下default 上是可以执行的 但是为啥用auto作为另一个task不能运行