13

Every time I deploy my Rails 3.2 project to Heroku, rake assets:precompile is run:

$ git push heroku master  
...
----> Preparing app for Rails asset pipeline
      Running: rake assets:precompile
      Asset precompilation completed (189.17s)
...

Sometimes I want to make a push that I know does not change any assets, such as a quick hotfix to a controller. Is it possible to skip the asset:precompile step for a single git push to Heroku?

Thanks.

Eli
  • 552
  • 1
  • 6
  • 15

4 Answers4

14

Sure! You'll need to create a manifest.yml in your_app/pubilc/assets directory.

The file can be blank. But ideally, you precompile everything locally, so deploys to Heroku would be much faster.

Make sure that you also committed the manifest.yml file when you're pushing to Heroku. Something like git add -f your_app/pubilc/assets/manifest.yml and a git push heroku master should suffice.

Benjamin Tan Wei Hao
  • 9,621
  • 3
  • 30
  • 56
  • If I still want assets to compile on Heroku most times, this solution means I would have to make one checkin to the manifest.yml file, push to heroku, then be absolutely sure to remove that file. Right? Is there any way that would not involve this additional step? – Eli Jul 22 '12 at 06:38
  • 2
    If you look carefully when you're deploying to Heroku, there would be a line which says something like `detected manifest.yml. Assuming assets compiled locally`. So essentially the manifest file is a signal to tell Heroku not to perform asset compilation. I think you can always manually run `heroku run rake assets:precompile` on your console. – Benjamin Tan Wei Hao Jul 22 '12 at 06:53
  • 5
    Running `heroku run rake assets:precompile` from your console will **not** precompile assets for your running Heroku dyno. Each process running on Heroku is run in different virtual environments. – Benjamin Manns Nov 05 '13 at 22:14
  • Hi @BenjaminManns, here is what Heroku have to say: https://devcenter.heroku.com/articles/rails-asset-pipeline. In particular, "There are two ways you can use the asset pipeline on Heroku. Compiling assets locally. Compiling assets during slug compilation." – Benjamin Tan Wei Hao Nov 06 '13 at 01:53
  • 1
    @BenjaminTan, right, but running the CLI command will do neither, as it isn't during slug compilation, and it isn't added to the git index. – Benjamin Manns Nov 07 '13 at 18:23
3

This worked for me. manifest.yml did nothing for me on my rails 4 project.

https://gist.github.com/Geesu/d0b58488cfae51f361c6

Geesu
  • 5,928
  • 11
  • 43
  • 72
1

Just precompile locally with rake assets: precompile, check in the resulting assets that are in public/assets, and push to heroku.

This will automatically create the manifest-.yml or json file in your public/assets directory; then heroku will detect that and report Detected manifest file, assuming assets were compiled locally.

Note 1: Some people have a line in development.rb that makes these go to public/dev-assets instead; if so, you need to rename dev-assets to just assets)

Note 2: Make sure your .gitignore file is not excluding the public/assets directory.

Ben Wheeler
  • 6,788
  • 2
  • 45
  • 55
0

In rails 4, create the file manifest-<md5 hash>.json instead of manifest.yml

megyewodi
  • 171
  • 1
  • 3