Open johnpapa opened 10 years ago
@johnpapa doesn't that line:
.pipe(gulp.dest(pkg.paths.stage)) // write the index.html file changes
... write out all the files in the (at that very moment unfiltered) stream instead of only index.html .. unnecessarily writing over the files already written by
.pipe(gulp.dest(pkg.paths.stage)) // write the rev files
... which gets executed at an earlier point of time in your pipe?
Applying some of your lessons from the pluralsight gulp.js course, I currently got kinda stuck with a similar issue:
gulp.task( 'rev', function () {
var filesToRevision = [
config.frontend + config.jsBuildMainFile,
config.frontend + config.jsBuildLibFile,
config.frontend + config.stylesBuildFile
];
var filesToRevisionFilter = $.filter([
config.jsBuildMainFile,
config.jsBuildLibFile,
config.stylesBuildFile
]);
var filesToReplaceWithin = [
config.frontend + config.htmlBuildFile,
config.frontend + 'bootstrap.js'
];
//var filesToReplaceWithinFilter = $.filter([
// config.htmlBuildFile,
// 'bootstrap.js'
//]);
return gulp.src( filesToRevision.concat( filesToReplaceWithin ))
.pipe( filesToRevisionFilter )
.pipe( $.rev())
.pipe( filesToRevisionFilter.restore())
// TODO: why is gulp-rev-replace not working inside another filter ??
//.pipe( filesToReplaceWithinFilter )
.pipe( $.revReplace())
//.pipe( filesToReplaceWithinFilter.restore())
.pipe( gulp.dest( config.buildFolder ));
});
Does someone know why rev-replace isn't working inside another filter? The code above is working but rev-replace is substituting in the filenames containing the revision during the second gulp.dest
not only in filesToReplaceWithin
(e.g. index.html
) but in filesToRevision
itself as well.
There might be cases when you exactly want to do this. But I guess in general, except the file names, you'd want to have those file's contents untouched.
Any help would be appreciated.
Why would that happen?