Skip to content
Buildpack to remove unwanted files from the slug post-build
Branch: master
Clone or download
Pull request Compare This branch is 4 commits ahead of moravcik:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Post-build Clean Buildpack

A simple buildpack to run after all other buildpacks have completed, which removes a set of files defined in .slug-post-clean, so that they are not included in the finished slug.


While this may seem to duplicate functionality provided by Heroku's .slugignore, there is a key difference: .slugignore'd files are removed after the repo is cloned, but before any buildpack is run. They can therefore not be involved in the build process itself.

However, it is not uncommon for there to exist files in the repo that are necessary for the build, but are not required at runtime. There may also be installable build dependencies that are not runtime dependencies.

Use cases include:

  • Large installation of node modules, all of which are used only for building the production assets, but then remain part of the slug.
  • Test and spec folders in Gem dependencies stored in vendor/bundle


You will need to use the heroku-buildpack-multi buildpack, and add your existing buildpack(s) to the .buildpacks file in your application repository. The post-build-clean buildpack must be last in the buildpack order:

# .buildpacks

The .slug-post-clean file supports file globs (including file/directory names with whitespace, but NOT new lines) e.g.:

You can’t perform that action at this time.