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.
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
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'
This gem does not execute or modify your Bower configuration or components.
- Run
$ bower install
whenever you modifybower.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.
- Include
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
]
- BOWER_PREFIX
- default: none - Path prefix for Bower asset URL substitutions, handy for unique CDN setups.
config.action_controller.asset_host
applies as normal.
The gem is available as open source under the terms of the MIT License.