Skip to content

Buildpack to remove unwanted files from the slug post-build

License

Notifications You must be signed in to change notification settings

QultureRocks/qr-post-build-clean-buildpack

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

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.

Rationale

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.

In our case, a complex front-end build involves significant CSS, JS and image assets, along with a large installation of node modules, all of which are used only for building the production assets, but then remain part of the slug.

Usage

You can use Heroku's multi-buildpack support to add this buildpack to your existing buildpack(s). The post-build-clean buildpack must be last in the buildpack order, which the following command will ensure:

heroku buildpacks:add qulture/post-build-clean

The .slug-post-clean file supports single-file and single-directory declarations only, e.g.:

some_huge_file.psd
some/nested/directory
why_does_this_app_even_contain_a.tiff

Remember to add a trailing line in the end of the file

Using the latest source code

The qulture/post-build-clean buildpack from the Heroku Buildpack Registry represents the latest stable version of the buildpack. If you'd like to use the source code from this Github repository, you can set your buildpack to the Github URL:

heroku buildpacks:add https://github.com/QultureRocks/qr-post-build-clean-buildpack.git

About

Buildpack to remove unwanted files from the slug post-build

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%