Rasterization plugin for gulp. It`s build on phantomjs, but, in contrast to svg2png, does not deal with fs(creating or reading tmp files).
First, install gulp-raster
as a development dependency:
npm i -S gulp-raster
Then, add it to your gulpfile.js
:
var raster = require('gulp-raster');
var rename = require('gulp-rename');
gulp.src('./src/**/svg/*.svg')
.pipe(raster())
.pipe(rename({extname: '.png'}))
.pipe(gulp.dest('./dist')),
You also can specify scale and file format. Let`s say you want get icon set for retina:
var raster = require('gulp-raster');
var rename = require('gulp-rename');
gulp.src('./src/**/svg/*.svg')
.pipe(raster({format: 'jpg', scale: 2}))
.pipe(rename({extname: '.jpg', suffix: '-2x'})
.pipe(gulp.dest('./dist')),
Type: Number
Default: 1
Set scale rate of output image.
Type: String
Default: png
Set output file format, png/jpg are available.