11

I deploy code to my production server using git. This might include changes to JS and CSS files.

Do I have to run rake assets:clean at all before I run rake assets:precompile? I'm worried that not cleaning the previous precompiled assets might have side effects.

This is a little silly, but my google-fu didn't find any answers. My AWS instance runs rake assets:clean pretty slowly and I'm wondering if it's needed at all.

Also, can I replace the clean command with a simple rm -r public/assets?

Damon Aw
  • 4,722
  • 4
  • 28
  • 37

1 Answers1

12

No you do not need to run rake assets:clean before, just running rake assets:precompile will recompile your assets. It will recreate your cache busting digest and manifest.yml (which contains key/value mappings that match each asset name to its MD5 cache-busted name)

and yes you can just run rm -r public/assets

Kyle C
  • 4,077
  • 2
  • 31
  • 34
  • To be thorough, there won't be any legacy files from the last precompile left in the public/assets directory if you dont clean? – Damon Aw Aug 24 '12 at 05:42
  • I believe the assets folder will only consist of what was precompiled. You can double check if deleted assets still show up but they should not be listed in the manifest.yml which maps everything together – Kyle C Aug 24 '12 at 15:41
  • Kyle, this is what I'm seeing as well. When I run rake assets:clean it doesn't remove the previous version of my compiled CSS files. I'm wondering if maybe it keeps the previous version around on purpose? – Wes Gamble Aug 15 '13 at 20:54
  • Wes, Are you precompiling for Development or Production? Did you try "rm -r public/assets"? – Kyle C Aug 16 '13 at 17:13
  • I got this error due to not cleaning before: http://stackoverflow.com/questions/29063613/rake-aborted-argumenterror-same-file – simo Mar 15 '15 at 17:36