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:
- Tests or specs
- Art sources (like .psd files)
- Design documents (like .pdf files)
- Test data (for example, the feedtools gem has 11 megs of XML sample files for its unit tests)
Thanks to Terence Lee and Matthew Todd for helping me discover .slugignore.