1

I'm running a Rails 3.2 app on Heroku, and thus am required to use the asset pipeline.

One thing that has seriously confused me for a while now about the Rails asset pipeline is the result of this little experiment:

git rm -r public/assets

git commit -m "Nuke all generated assets"

RAILS_ENV=production bundle exec rake assets:precompile

git add .

RAILS_ENV=production bundle exec rake assets:precompile

Specifically, if I examine the difference between my staged and unstaged changes, I find that the second asset precompilation has regenerated/refingerprinted/reminified all my CSS and JS.

Why should that occur when I changed nothing between asset compilations?

Obviously the current timestamp is somehow involved, but why is that so when - again - I changed nothing?

Finally, is there any way to change asset precompilation such that CSS and JS assets are only regenerated if they were changed since the last precompilation?

aec
  • 833
  • 1
  • 9
  • 18

2 Answers2

1

You can do it using a Capistrano, and basically checking the current deploy against the old version and see which files changed. This is where I learned about it.

https://github.com/capistrano/capistrano/issues/227 http://www.bencurtis.com/2011/12/skipping-asset-compilation-with-capistrano/

rovermicrover
  • 1,453
  • 1
  • 15
  • 21
0

It will change, because every time you create a new gzip file, even if the contents are the same, the resulting file will be different, and source control systems don't know how to deal with this (and it's not supposed to do it).

You should take a look at this answer to know what files to add to gitignore.

Also you can take a look at this discussion about it in github.

Community
  • 1
  • 1
Paulo Fidalgo
  • 21,709
  • 7
  • 99
  • 115