Reputation: 23276
I know the pipe function in NodeJs. A readable stream calls the pipe function with the first argument being the writable stream. Something like:
readable.pipe(fs.createWriteStream('file.txt'));
This will pipe all the output to file.txt
. But I have not understood this in context of gulp
.
What does a call to a pipe function like:
gulp.src('./assets/styles/**/*.scss')
.pipe(sass());
mean? Here is the full snippet:
var gulp = require('gulp');
var gutil = require('gulp-util');
// require sass
var sass = require('gulp-ruby-sass');
gulp.task('sass', function () {
gulp.src('./assets/styles/**/*.scss')
.pipe(sass())
.pipe(gulp.dest('./assets/styles'));
});
gulp.task('default', ['sass']);
I understand the dest
part. But do not understand the pipe(sass())
part. What does it do? What stream does each of these functions return?
Note: I have taken the sample example from a blog
Upvotes: 1
Views: 1257
Reputation: 47222
The pipe
in gulp is the exact same as the pipe
in Node.
This flow streams the sources files from .src()
and creates a new stream a pipes it through the sass plugin - the sass plugin will then process all sass files into css and concat them to the destination path as a new stream.
Upvotes: 1