samedi 9 janvier 2016

Rails rev assets using Gulp

Vote count: 0

I am reading the guide on this site: http://ift.tt/1urqEkw

and I read the following part:

Rev This is my favorite part of using Gulp. Rev will give you that friendly app-ef62e7.js filename output that Asset Pipeline is famous for. The reason for it is you can cache it forever. New requests will just point to new files. CDNs love this. To get the files to have the hash is pretty easy with Rev.

var rev = require('gulp-rev');

gulp.task('rev', ['less', 'scripts'], function() { return gulp.src(['dist//.css', 'dist//.js']) .pipe(rev()) .pipe(gulp.dest('dist')) .pipe(rev.manifest()) .pipe(gulp.dest('dist')); }); view rawgulpfile.js hosted with ❤ by GitHub Now the filename has the hash appended to it! Note the digest I generate as well; that looks like the following:

{ "app.css": "app-1c1d3237.css", "app.js": "app-26ad0c3f.js" } view rawrev-manifest.json hosted with ❤ by GitHub Here is where a bit of custom code would come into play. When you generate your index.html (or wherever else you reference the CSS/JS) you will have to swap out the URL for the one in the digest file. Should only be a matter of parsing this JSON file in your framework of choice, or having Gulp rewrite your index.html to replace the CSS/JS include with the correct filename.

This is all well and good and sounds fine to me but if I do that and Gulp injects the new filenames for my main css and js files then my git version control system is going to pick up this as a change EVERY SINGLE TIME I update my assets.

How do people deal with this?

asked 2 mins ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Rails rev assets using Gulp

Aucun commentaire:

Enregistrer un commentaire