L
L
lavezzi12015-12-26 03:47:26
JavaScript
lavezzi1, 2015-12-26 03:47:26

How to make one task from two tasks in gulp?

Hello.
There are two tasks:

gulp.task('sprites', function () {
  return gulp.src(src.source + 'img/svg-files/**/*.svg')
    .pipe(svgSprite())
    .pipe(gulp.dest(src.source + 'img/svg-sprites/')) // Write the sprite-sheet + CSS + Preview
    .pipe(filter(src.source + '/img/svg-files/**/*.svg'))  // Filter out everything except the SVG file
});

gulp.task('svg2png', function () {
  gulp.src(src.source + 'img/svg-sprites/**/*.svg')
    .pipe(svg2png())
    .pipe(gulp.dest(src.source + 'img/png-sprites/'));
});

It needs to be merged into one. Moreover, such a task is registered in the documentation for https://www.npmjs.com/package/gulp-svg-sprites
, but pngs are not created. What's wrong?
var svgSprite = require("gulp-svg-sprites");
var filter    = require('gulp-filter');
var svg2png   = require('gulp-svg2png');
 
gulp.task('sprites', function () {
  return gulp.src(src.source + 'img/svg-files/**/*.svg')
    .pipe(svgSprite())
    .pipe(gulp.dest(src.source + 'img/svg-sprites/')) // Write the sprite-sheet + CSS + Preview
    .pipe(filter(src.source + '/img/svg-files/**/*.svg'))  // Filter out everything except the SVG file
    .pipe(svg2png())           // Create a PNG
    .pipe(gulp.dest(src.source + 'img/svg-sprites/png/'));
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kravchenko, 2015-12-26
@mydearfriend

so in the stream and without filter only svg files
try
filter('**/*.svg')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question