Giter VIP home page Giter VIP logo

heroku-buildpack-post-build-clean's Introduction

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

Add the buildpack to your app using the Heroku CLI: heroku buildpacks:add https://github.com/vintasoftware/heroku-buildpack-post-build-clean. The post-build-clean buildpack must be last in the buildpack order:

$ heroku buildpacks

=== test-app-12345 Buildpack URLs
1. heroku/nodejs
2. heroku/python
3. https://github.com/vintasoftware/heroku-buildpack-post-build-clean

The .slug-post-clean file supports single-file and single-directory patterns, as well as glob patterns, e.g.:

some_huge_file.psd
some/nested/directory
why_does_this_app_even_contain_a.tiff
your_frontend/build/*.map

Glob patterns are expanded using Bash syntax - not with a third-party library such as node-glob. You can see what your glob matches from bash with this command:

ls -d1 your/glob/pattern/*

Testing

The bin/compile script does all the heavy lifting for this package. It takes a single argument, $BUILD_DIR, the directory of your app. If you want to test it out locally and make sure your app still runs after the post-build cleanup, you can copy bin/compile into your app directory and run:

chmod +x compile; ./compile .

heroku-buildpack-post-build-clean's People

Contributors

urbanautomaton avatar fjsj avatar mcmillan avatar moravcik avatar nruth avatar vladstoick avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.