Require CommonJS modules, JSON files or files with JS-expression inside gulp tasks with ease.
gulp-eval fills data property of Vinyl objects.
vargulp=require('gulp');varconcat=require('gulp-concat');vargulpEval=require('gulp-eval');varthrough=require('through2');gulp.task('default',()=>gulp.src('node_modules/*/package.json').pipe(gulpEval()).pipe(through.obj(function(file,enc,next){vardata=file.data;// Here we have evaluated package.jsonfile.contents=newBuffer(data.name+'#'+data.version);next(null,file);})).pipe(concat('packages.txt')).pipe(gulp.dest('dest/')));You can provide some like-a-global variables into gulp-eval
vargulpEval=require('gulp-eval');varglobalVar=42;vartransformStream=gulpEval({globalVar: globalVar});// globalVar will be in context of evaluated codeCode and documentation © 2016 YANDEX LLC. Code released under the Mozilla Public License 2.0