简体   繁体   中英

where are my font files - in my Rails project I use Bower and Material Design

Bootstrap-Material-Design by FezVrasta is a very nice module! I only have one tiny itch - and that is pertaining to the fonts addressed in the material.css

I'm on Ruby 2.1.2, Rails 4.1.5, Node 0.10.35 and Bower 1.3.7

I added a .bowerrc with

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

then I put gem "bower-rails", "~> 0.9.2" in my Gemfile

and then I listed the bower packages in Bowerfile

# A sample Bowerfile
# Check out https://github.com/42dev/bower-rails#ruby-dsl-configuration for more options
# asset 'bootstrap'

asset "jquery", "2.1.1"
asset "jquery-ujs", "1.0.1"
asset "sweetalert", "0.2.0"
asset "bootstrap-material-design", "0.2.2"
Then I did my bower install – and everything was perfect!

But after cap production deploy I have to go and do on my app servers this:

cd public && ln -s /var/www/clock/current/vendor/assets/bower_components/bootstrap-material-design/fonts fonts

Or else my browser barfs with

Failed to load resource: the server responded with a status of 404 (Not Found)
http://irrelevant.domain/fonts/Material-Design-Icons.woff?-g7cqhn
Is there a way around this?

It's not like I cannot automate the symbolic linking - it just seems kind'a sticking a band-aid on :)

How much I really wanted to use Bower to manage the client side assets, I reverted to letting Bundler do the heavy lifting :/

There is a 'service' - https://rails-assets.org/ - a kind of 'gem wrapping giftshop' that I've used; and as it turned out to be: will continue to use.

It's sweet and easy and all you have to do is follow the short recipe right on the landing page.

Added this snippet to my Gemfile

source 'https://rails-assets.org' do
  gem 'rails-assets-sweetalert'
  gem 'rails-assets-jquery'
  gem 'rails-assets-jquery-ujs'
  gem 'rails-assets-bootstrap-material-design'
end

kept my require's in application.js and application.scss and waisted all the bower.json, Bowerfile, vendor/assets/bower_components folder etc

and did one last bundle install

Case closed :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM