Skip to content

Removes all node_modules from your Heroku slug to keep it as small as possible (and avoid maximum slug size issue)

Notifications You must be signed in to change notification settings

RoleModel/heroku-buildpack-node-modules-cleanup

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

Heroku Buildpack: Node Modules Cleanup

Remove all node_modules directories after the build process is completed.

Delete the node_modules directories

The maximum allowed Heroku slug size (after compression) is 300MB. Image-heavy apps can somethings butt up against this limit, especially when using multiple buildpacks. If you're using Node.js to compile your front-end assets, but not to run your app, you may be able to save a large amount of space by deleting the node_modules directory before slug compilation.

Usage

First, set the Node.js buildpack to compile your assets:

$ heroku buildpacks:set heroku/nodejs

Next, add the Node Cleanup buildpack to get rid of the node_modules directory:

$ heroku buildpacks:set --index 1 https://github.com/RoleModel/heroku-buildpack-node-modules-cleanup

For review apps, also add it to your app.json file:

{
  "name": "Multi-lang Masterpiece",
  "scripts": {
    "postdeploy": "bin/rails db:seed"
  },
  "buildpacks": [
    {
      "url": "heroku/metrics"
    },
    {
      "url": "heroku/nodejs"
    },
    {
      "url": "heroku/ruby"
    },
    {
      "url": "heroku/python"
    },
    {
      "url": "https://github.com/RoleModel/heroku-buildpack-node-modules-cleanup.git"
    }
  ]
}

Documentation

For more general information about buildpacks on Heroku:

About

Removes all node_modules from your Heroku slug to keep it as small as possible (and avoid maximum slug size issue)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%