joemaller joemaller - 5 months ago 33
Node.js Question

Gulp pipe minimal function?

What is smallest function that can be placed in a Gulp pipe and still work?

This doesn't work:

gulp.src('**')
.pipe(function() {
// what's the minimum that can go here and still be a functional pipe?
// what needs to be returned?
});


Ideally this would be vanilla JS using only the foundational modules Gulp was built on; vinyl, through, etc.

Answer

The problem with your pipe is that you're dropping the files of your glob since you don't return them.

Using through2, you can do something like this:

var through = require('through2');

gulp.src('**')
  .pipe(through.obj(function (file, enc, cb) {
    cb(null, file);
  }));
Comments