Bowerinstaller
rake task to install bower packages to rails. This project is inspired by
bower, bower-installer, and bower-rails. The rake task uses bower to
manage the package dependencies and download the required bower packages.
Then it follows the mechanism similar to bower-installer to install js/css
to the proper location. Once that is done, it will then generate a
component.js and component.css file to require all the installed js/css file.
component.js/css can then be included by application.js/css.
Requirement
Install
Add this line to your application's Gemfile:
gem 'bowerinstaller'
bower.rb
Instead of using bower.json, bowerinstaller uses a DSL approach, similar to
Gemfile. bower.rb must be created in your Rails application's root directory.
Here is an example:
group :vendor do
package :jquery, "1.8" do
do_not_install
end
package :handlebars, "1.0.0-rc.3" do
source 'handlebars.js'
end
package :datatables, "1.9.4"
end
The other support group is :lib.
Available command
rake bower:install # install bower packages
rake bower:unindstall # uninstall bower packages
Note
After you run bower:install, the required js/css will be installed under
/vendor/assets/components folder. It will also generate
/app/assets/javascripts/components.js and /app/assets/stylesheets/components.js.
You can explicitly require these two files in your application.js and application.css.
This will ensure any vendor packages you add in the future will be automatically
included into your app.