Matt's Blog

Exclude Static Assets From Heroku Slug Without Removing From Repository Using .slugignore

by Matt Hodan on August 20, 2010

Want to reduce the size of your Heroku slug? Easy– move your static assets to Amazon S3. Great, problem solved, but wait… What do you do with the static assets left in your repository?

I found myself asking this question today…

My first though was to use “.gitignore”, which would exclude the static assets from my git repository and in turn my Heroku slug. However, this approach would leave me without version control of my static assets. Not ideal…

Then I did a little research and came up with this better approach: “.slugignore”. Just like .gitignore, .slugignore sits in your project folder and identifies files to ignore. However, instead of excluding specified files from your git repository, it excludes them only from your slug. Genius!

Heroku has a great explanation of .slugignore in their docs. These are some examples of files that Heroku notes you may wish to include in your .slugignore:

Thanks to Terence Lee and Matthew Todd for helping me discover .slugignore.

comments powered by Disqus

Recent Articles