Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Not manifesting/versioning CSS & JS #33

Open
mvarrieur opened this issue Sep 13, 2015 · 7 comments
Open

Not manifesting/versioning CSS & JS #33

mvarrieur opened this issue Sep 13, 2015 · 7 comments

Comments

@mvarrieur
Copy link

Not sure if this is intentional or not, but I'm adapting this to my project and realized since the font versioning fix this (this commit: bf106ea#diff-e88ef86846aa4dbfb9831f43405256fd) seems to be excluding CSS and JS files because of this line:

https://github.com/vigetlabs/gulp-rails-pipeline/blob/master/gulp/tasks/rev/rev-assets.js#L7

I can't get this project to run locally so I can't test for sure, but it seems unintentional to me.

@greypants
Copy link
Contributor

Good question.

That's actually intentional... or at least it was at one point. Originally, I was recommending including the generated css and js files into app/assets/{javascripts,stylesheets}/application.{css,js}, in which case, Rails would take care of revisioning the files.

In the original version of this based on gulp-starter. I'm revisioning in multiple steps.

  1. First, hit all the assets, so their filenames change first.
  2. Then replace the changed filenames in css and js files.
  3. Now we can revision the css and js files. If any child asset filenames have changed, the css and js file will have changed too, which will change the newly generated hash.

If we versioned everything at the same time, the hash of the css and js files wouldn't change as a result of referenced assets changing, and you could have cached files being served pointing to old filenames.

But I guess I stripped out those later steps and decided to let Rails handle that bit. Not sure if I still agree with that decision or not, but that's the state of things.

At some point, I need to get this up to date with gulp-starter

@davidham
Copy link

@greypants thanks for the response. I'm using gulp-rails-pipeline for my app but I'm not using browserify--I'm still doing AMD modules. My rev-manifest.json has a font file, my one graphic file, a CSS sourcemap, and a js file named bind.polyfill.js, which I guess gets past your pattern in the commit referenced above. Was your intention to have your gulp pipeline create the global.js bundle and the Sass-ified CSS file, and then have the developer =require them in application.js and application.css? So if I were to build my JS file on the gulp side and then require it from the Rails side, the revving should work? Thanks for any advice you can offer--I love the project and your Viget blog, which has helped me a number of times.

@greypants
Copy link
Contributor

@davidham yep, that's the gist of it. Rails's rake assets:precompile command will still rev and compress anything in the pipeline. So like you said, if you =require the files into the pipeline, you can use the rails revisioned files (that include your gulp-processed files) instead.

@davidham
Copy link

@greypants Would your new webpack tasks from gulp-starter-2 work in gulp-rails-pipeline, like in place of browserify/watchify? I had been thinking of getting started with webpack because I can still use my AMD files. Thanks again!

@greypants
Copy link
Contributor

The file and configuration structure has changed quite a bit, so just doing a drop in replacement might require some figuring out, but yeah, that could work. I'll try to get this thing up to date in the next week, once I get gulp-starter 2.0 merged into master... which will be this week!

@davidham
Copy link

Sounds awesome! I got gulp-starter-2 working with my Rails app, seems like it's pretty straightforward and mostly driven by the path settings in the config file. Nice work!

@greypants
Copy link
Contributor

@davidham yesssssss! That is music to my ears. So good to hear.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants