Created
August 26, 2014 12:43
-
-
Save thomasmb/906302bc9519be8abed5 to your computer and use it in GitHub Desktop.
Filtering empty files in gulp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'), | |
filter = require('gulp-filter'), | |
changed = require('gulp-changed'), | |
imagemin = require('gulp-imagemin') | |
var paths = { | |
images: './source/img/**/*' | |
}; | |
// Process images | |
gulp.task('images', function() { | |
var dest = './assets/img'; | |
return gulp.src(paths.images) | |
// ignore empty files | |
.pipe(filter(function(a){ return a.stat && a.stat.size })) | |
// Don't run the same files twice | |
.pipe(changed(dest)) | |
// Optimize images | |
.pipe(imagemin({optimizationLevel: 5})) | |
.pipe(gulp.dest(dest)) | |
}); | |
gulp.task('default', ['images']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment