Read more

Managing vendor assets in Rails with Bower

Thomas Klemm
October 29, 2014Software engineer

bower-rails Show archive.org snapshot is a great solution for managing vendored assets in your Rails app. It feels especially much more convenient and easier to update assets when going this way.

Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

bower-rails generates a Bowerfile that works much like the Gemfile you're used to. Just specify your dependencies and run rake bower:install. You can find available packages here Show archive.org snapshot .

An example Bowerfile:

# ./Bowerfile
asset 'angular'
asset 'angular-i18n'
asset 'angular-ui-router'
asset 'angular-ui-bootstrap'
asset 'lodash'
asset 'restangular'
asset 'moment', '1.2.3'

The following commands are available via rake (there are more, these are the main ones only):

$ rake -T | grep bower
# =>
rake bower:install # Install components from Bowerfile
rake bower:list # List bower components
rake bower:update[<component>]
rake bower:update:prune # Update existing components and uninstalls extraneous components

To update multiple (but not all) components, you can run rake bower:update with a comma separated list of components:

rake bower:update[angular,angular-i18,angular-cookies,angular-animate,angular-sanitize,angular-mocks]

Also see bower-rails can rewrite your relative asset paths.

Posted by Thomas Klemm to makandra dev (2014-10-29 10:21)