jamesknelson / gulp-rev-replace

Rewrite occurences of filenames which have been renamed by gulp-rev
MIT License
389 stars 62 forks source link

Have to run rev and rev-replace separately or it fails #36

Open LZ-TimHunold opened 9 years ago

LZ-TimHunold commented 9 years ago

Just as it says, if I use the example given, it creates the rev, writes the manifest, but does not change the html file until i run the tasks again. I tried to add a wait task in there with no luck. I have a very minute theory that virus scan is reading the manifest file and the task cannot read it so I run this as two new tasks and that is just enough time.

gulp.task("step1", function () { gulp.src('./src/assets/css/global.css') .pipe(gulp.dest('./web/assets/css')) .pipe(rev()) .pipe(gulp.dest('./web/assets/css')) .pipe(rev.manifest()) .pipe(gulp.dest('./web/assets/css')) .pipe(wait(5000)) });

gulp.task("step2", function(){ var manifest = gulp.src("./web/assets/css/rev-manifest.json"); return gulp.src("./src/index.html") .pipe(wait(5000)) .pipe(revReplace({manifest: manifest})) .pipe(wait(5000)) .pipe(gulp.dest("./web/")); });

jlengstorf commented 9 years ago

I was dealing with a similar issue, but I was able to solve it by creating two watch tasks.

Using your task names/paths from above, you could try something like this:

gulp.task('watch', function(  ) {
  gulp.watch('./src/assets/css/global.css', ['step1']);
  gulp.watch('./web/assets/css/rev-manifest.json', ['step2']);
});
zjjott commented 8 years ago

rev-replace only success once when gulp watch begin,and then,after then,watch task always write a empty file to dist file....why?

alex-shamshurin commented 8 years ago

I can confirm the same issue.

LorenzGardner commented 8 years ago

I'm having similar issues. I have to have them as separate tasks, and them manually to get them to work. Even running the rev on a pre-build step, and rev-replace on a post build step fails.

When it fails, it seems like the call from

.pipe(rev-replace(options))

never returns.

alex-shamshurin commented 8 years ago

Do we have some progress?

LorenzGardner commented 8 years ago

As as workaround I just used the built in node FS module to read the file in question, and replace the site.js with the file name from the rev manifest. It works 100% of the time, and is only a few lines of JS.

This was trivial in my case as I only needed to replace one file. But, while waiting for this npm module to get an update you might choose to roll your own.

alex-shamshurin commented 8 years ago

I use "return true" as a workaround, instead of returning stream and it's works