In the gulp -newer options documentation, I read that it supports passing in a configuration object instead of a destination. In this configuration object, you can specify the mapping function from old to new files. Therefore, instead of
newer('_build')
You can write
newer({dest: '_build', map: mappingFn})
, - . index.js. , rev-manifest.json, . - script ( ):
gulp.task('rev-js', function() {
var currentManifest = JSON.parse(fs.readFileSync('rev-manifest.json', 'utf8'));
function mapToRevisions(relativeName) {
return currentManifest[relativeName]
}
return gulp.src('/js/main.js, {base: '.'})
.pipe(newer({dest: '_build', map: mapToRevisions}))
.pipe(rev())
.pipe(gulp.dest('_build'))
.pipe(rev.manifest())
.pipe(gulp.dest('_build/rev/js'));
});