jamesknelson / gulp-rev-replace

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

Not understanding the documentation #41

Closed sqorandy closed 8 years ago

sqorandy commented 8 years ago

I am pretty green when it comes to using Gulp, and I am trying to implement some cache-busting into an application using the gulp-rev-replace plugin along with gulp-rev. I can get the files to be renamed with a hash, and I am able to generate a rev-manifest.json file, but I am stuck with the replacing part.

What is throwing me for a loop specifically is this:

gulp.task("revreplace", ["revision"], function(){ var manifest = gulp.src("./" + opt.distFolder + "/rev-manifest.json");

return gulp.src(opt.srcFolder + "/index.html") .pipe(revReplace({manifest: manifest})) .pipe(gulp.dest(opt.distFolder)); });

What is it referring to specifically when you called .pipe(revReplace({manifest: manifest}))????

chshouyu commented 8 years ago

It is means use the file map in rev-manifest.json to replace ref

For example, if in your rev-manifest.json you have:

{"js/app.js": "js/app-98adc164.js"}

and in your html file

<script src="js/app.js"></script>

the result will be

<script src="js/app-98adc164.js"></script>
jamesknelson commented 8 years ago

@sqorandy is this solved? If you were able to write up improved documentation based on what you learnt, I'd be happy to merge.

sqorandy commented 8 years ago

@jamesknelson @chshouyu : Thank you for your responses. I appreciate the info. The plugin is working great. It turns out the issue had to do with the order of the tasks being run in my views.js file. When I have some time I will try to do an update for the docs. Cheers