Ответ 1
Взгляните на Документы плагинов для вложений.
Вы хотите создать поток преобразования. Взгляните на этот Справочник по потокам. В вашем случае вы хотите map
поток и изменить его по мере его поступления. Самый простой способ - (в 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);
}