0.0
No commit activity in last 3 years
No release in over 3 years
Import externally managed Bower assets via Rails Sprockets while preserving links to relative dependencies, and maintaining hash digests in production.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.13
~> 5.0
~> 10.0

Runtime

 Project Readme

Bower Sprockets for Ruby on Rails

Join the chat at https://gitter.im/binarybabel/Latestver Gem Version

Bower asset processor for Rails 4/5 Sprockets, featuring:

  • CSS/JS URL Rewriting for images, fonts, etc.
  • Support for production Hashes/Digests

A rewrite/evolution of the Gem Bowerify, with new capabilities.

Installation

Add this line to your application's Gemfile:

gem 'accio_bower'

And this line to a new/existing .bowerrc file:

{"directory": "vendor/assets/bower_components"}

If you DO NOT yet have a bower.json file:

$ bundle install
$ bower init    # follow instructions
$ bower install --save SOME-BOWER-DEPDENDENCY

If you ALREADY have a bower.json file:

$ rm -rf bower_components
$ bundle install
$ bower install

To include CSS/JS files in your application

Use the name of the file under the vendor/assets/bower_components path.

For example, to include font-awesome in application.css:

 *= require 'font-awesome/css/font-awesome.min'

You'll still need $ bower install

This gem does not execute or modify your Bower configuration or components.

  • Run $ bower install whenever you modify bower.json
  • If you're building in a sandbox, CI, Docker, Heroku, etc.
    • Include $ bower install; bower prune in your build-script.
    • Consider saving/restoring vendor/assets/bower_components as a build cache.

Configuration

Ruby Initializer

app/config/initializers/bower.rb

Rails.application.config.accio_bower.components = [
  Rails.root.join('vendor', 'assets', 'bower_components')
]
Rails.application.config.accio_bower.extensions = %w[
  png gif jpg jpeg ttf svg eot woff woff2
]

Environment Variables

  • BOWER_PREFIX
    • default: none - Path prefix for Bower asset URL substitutions, handy for unique CDN setups.
    • config.action_controller.asset_host applies as normal.

License

The gem is available as open source under the terms of the MIT License.