Answer the question
In order to leave comments, you need to log in
How to insert a file opening in the middle of a stream?
For example, there is gulpfile.js with the following content:
var gulp = require('gulp');
var svg2png = require('gulp-svg2png');
var spritesmith = require('gulp.spritesmith');
gulp.task('svg2png', function() {
// Модуль gulp.spritesmith не умеет читать содержимое файлов из потока, поэтому изображения сохраняются во временную директорию ./images/tmp
return gulp.src('./images/sprite/*.{svg}')
.pipe(svg2png())
.pipe(gulp.dest('./images/tmp/'));
});
gulp.task('default', ['svg2png'], function() {
var data = gulp.src('./images/tmp/*.{png}')
.pipe(spritesmith({
imgName: 'sprite.png',
cssName: 'sprite.css'
}));
data.img.pipe(gulp.dest('./images/'));
data.css.pipe(gulp.dest('./css/'));
});
gulp default
. How to implement all this procedure in one task (task)? Intuitively comes the idea to combine 2 streams:var gulp = require('gulp');
var svg2png = require('gulp-svg2png');
var spritesmith = require('gulp.spritesmith');
gulp.task('default', function() {
var data = gulp.src('./images/sprite/*.{svg}')
.pipe(svg2png())
.pipe(gulp.dest('./images/tmp/'))
.pipe(gulp.src('./images/tmp/*.{png}'))
.pipe(spritesmith({
imgName: 'sprite.png',
cssName: 'sprite.css'
}));
data.img.pipe(gulp.dest('./images/'));
data.css.pipe(gulp.dest('./css/'));
});
.pipe(gulp.src('./images/tmp/*.{png}'))
. Is it possible somehow to open a file inside a thread without creating new jobs?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question