Skip to content

Instantly share code, notes, and snippets.

@ayapi
Created June 26, 2014 02:21
Show Gist options
  • Save ayapi/4e8f806209d2d073cad3 to your computer and use it in GitHub Desktop.
Save ayapi/4e8f806209d2d073cad3 to your computer and use it in GitHub Desktop.
gulp-svg2png + gulp-newer + gulp-imagemin + pngquant
var gulp = require('gulp');
var newer = require('gulp-newer');
var svg2png = require('gulp-svg2png');
var imagemin = require('gulp-imagemin');
var pngquant = require('imagemin-pngquant');
var path = {
svg2png : {
src : 'svg/*.svg',
dest : 'img'
}
};
gulp.task('svg2png', function () {
return gulp.src(path.svg2png.src)
.pipe(newer({
dest: path.svg2png.dest,
ext: '.png' //←これをゎすれると全svgファイルを変換しちゃぅから注意
}))
.pipe(svg2png())
.pipe(imagemin({
use: [pngquant()]
}))
.pipe(gulp.dest(path.svg2png.dest));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment