Bob Nadler, Jr. Bob Nadler, Jr.

Heroku Slug Compiler Optimizations

Published about 11 years ago 1 min read
Night Train
Image by Kevin Dooley

Using .slugignore to reduce your slug size

This may be old news to some, but I recently learned about a cool Heroku feature: the .slugignore file.

What is it?

A .slugignore is like a .gitignore file for your app. It is used to reduce the size of your slug file on Heroku by ignoring files that are not essential for your app to operate.

Why is it cool?

The smaller the slug file for your app, the faster Heroku can transfer it across dynos, making scaling much easier. Heroku suggests keeping your slug file size under 50MB, files smaller than 15MB are preferred.

How do I use it?

Place it in your project's root folder. It works the same way as a .gitignore file does. The only difference is that it doesn't support the negation operator (!). See Heroku's documentation on its slug compiler for more information. Here are some suggestions of things that you may want to put in your .slugignore file:

  • Mockups and old versions of image assets
  • Any project documents, PDF's, etc.
  • Test files

Example .slugignore

test
docs
*.pdf

Share This Article