Last active
March 30, 2018 11:33
-
-
Save Simounet/0630e05c6bc918837531 to your computer and use it in GitHub Desktop.
Looking for the best way to repeat task 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 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