Updated for Rails 4.0.0+
-
Set up the
bower
gem. -
Follow the Bower instructions and list your dependencies in your
bower.json
, e.g.// bower.json { // ... "dependencies": { "d3": "~3.1.0", "underscore": "~1.4.4", } }
-
Include them in your JavaScript:
// app/assets/javascripts/application.js // // Bower packages //= require d3/d3 //= require underscore/underscore // //= require jquery //= require jquery_ujs // ...
-
Ignore the components in your repo. If you prefer to "vendor" your dependencies, skip this step.
# .gitignore /bower_components/
-
Install the components.
npm install -g bower bower install
At this point, make sure your app runs and the JS libs installed by Bower are loading on the page.
To have Heroku deploys (Cedar stack only) install and compile Bower components on push:
-
Use a custom Heroku buildpack that includes Node.js and Bower (see heroku/heroku-buildpack-ruby#67). If you vendored your components (skipping the
.gitignore
step above), you can skip this step and use the regular Ruby buildpack.heroku config:set BUILDPACK_URL='git://github.com/qnyp/heroku-buildpack-ruby-bower.git#run-bower'
Try a deploy: it should successfully compile assets.
Additional resources:
Thanks for this.
Do you know if anything has changed with rc2?
When I push to heroku, even with you gist, I see this: