Skip to content

Instantly share code, notes, and snippets.

@Simounet
Last active March 30, 2018 11:33
Show Gist options
  • Save Simounet/0630e05c6bc918837531 to your computer and use it in GitHub Desktop.
Save Simounet/0630e05c6bc918837531 to your computer and use it in GitHub Desktop.
Looking for the best way to repeat task in Gulp
var destination = imagesBase + '1x/';
var destinationRetina = imagesBase + '2x/';
gulp.task("default", function() {
spriteAndCompress( destination );
spriteAndCompress( destinationRetina, 'retina' );
});
function spriteAndCompress( destination, nameExtension ) {
var name = 'sprite';
if( typeof( nameExtension ) !== 'undefined' ) {
name += '-' + nameExtension;
}
gulp.src( destination + '*.png' )
.pipe(sprite({
name: name,
style: '_' + name + '.scss',
cssPath: imagesBase,
processor: 'scss'
}))
.pipe(imagemin({
optimizationLevel: 5,
progressive: true,
interlaced: true
}))
.pipe(gulp.dest( imagesBase ));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment