Take a look at the Writing Plugins docs.
What you want is to create a transformation stream. Take a look at this Stream Handbook. In your case, you want to map
the stream and change it as it goes. The easiest way would be (in JS):
gulp.src(src)
.pipe(makeChange())
.pipe(gulp.dest(dest));
function makeChange() {
// you're going to receive Vinyl files as chunks
function transform(file, cb) {
// read and modify file contents
file.contents = new Buffer(String(file.contents) + ' some modified content');
// if there was some error, just pass as the first parameter here
cb(null, file);
}
// returning the map will cause your transform function to be called
// for each one of the chunks (files) you receive. And when this stream
// receives a 'end' signal, it will end as well.
//
// Additionally, you want to require the `event-stream` somewhere else.
return require('event-stream').map(transform);
}