Skip to content

Commit

Permalink
cache client/node_modules during heroku deploys
Browse files Browse the repository at this point in the history
without this heroku has to do a full npm install on every deploy - i guess this could be part of the heroku generators but it seemed like a lot more work to modify this file there than to just add this option here.
  • Loading branch information
modosc committed Mar 28, 2016
1 parent e6fa8c4 commit 7e78ae4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 9 additions & 3 deletions docs/additional-reading/heroku-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ The generator has created the necessary files and gems for deployment to Heroku.
+ `config/puma.rb`: Puma webserver config file
+ `lib/tasks/assets.rake`: This rake task file is provided by the generator regardless of whether the user chose Heroku Deployment as an option. It is highlighted here because it is helpful to understand that this task is what generates your JavaScript bundles in production.

By default Heroku will cache the root `node_modules` directory between deploys but since we're installing in `client/node_modules` you'll need to add the following line to the `package.json` in your root directory (otherwise you'll have to sit through a full `npm install` on each deploy):
```
"cacheDirectories": [
"node_modules",
"client/node_modules"
],
```

## How to Deploy

React on Rails requires both a ruby environment (for Rails) and a Node environment (for Webpack), so you will need to have Heroku use multiple buildpacks.
Expand Down Expand Up @@ -64,6 +73,3 @@ bundle
bin/rake db:migrate
bin/rake db:setup
```



Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
"url": "https://github.com/shakacode/react-webpack-rails-tutorial/issues"
},
"homepage": "https://github.com/shakacode/react-webpack-rails-tutorial",
"dependencies": {}
"dependencies": {},
"cacheDirectories": ["node_modules", "client/node_modules"]
}

0 comments on commit 7e78ae4

Please sign in to comment.