Created
February 27, 2016 21:23
-
-
Save AndrejGajdos/c4103a84c66608049814 to your computer and use it in GitHub Desktop.
Second part of gulp tak – converting SVG Sprite to separate files
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'); | |
var config = require('./config.json'); | |
var del = require('del'); | |
var svg2png = require('gulp-svg2png'); | |
var graphicsmagick = require('gulp-gm'); | |
... | |
gulp.src("./build/svg_files_" + colorName + "/*.svg") | |
.pipe(svg2png()) | |
.pipe(gulp.dest("./build/png_files_" + colorName)) | |
.on('end', function() { | |
console.log(timestamp('[hh:mm:ss] ') + "PNG files were created"); | |
console.log(timestamp('[hh:mm:ss] ') + "Resizing PNG files..."); | |
gulp.src("./build/png_files_" + colorName + "/*.png") | |
.pipe(graphicsmagick(function(gmfile) { | |
return gmfile.resize(config.image.width, config.image.height); | |
})) | |
.pipe(gulp.dest("./build/png_files_" + colorName + "_" + config.image.width.toString() + "_" + config.image.height.toString())) | |
.on('end', function() { | |
del(["./build/png_files_" + colorName, "./build/svg_files_" + colorName], function(err, paths) { | |
if (err) { | |
return console.log(timestamp('[hh:mm:ss] ') + err); | |
} | |
}); | |
}); | |
console.log(timestamp('[hh:mm:ss] ') + "PNG files were resized"); | |
}); | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment