Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bower installation: wrong font path in rails #689

Closed
yordis opened this issue Aug 10, 2014 · 10 comments
Closed

bower installation: wrong font path in rails #689

yordis opened this issue Aug 10, 2014 · 10 comments

Comments

@yordis
Copy link

yordis commented Aug 10, 2014

I am using bower for install the dependency of bootstrap.

_.bowerrc_

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

_add components folder_ to the asset pipeline

config.assets.paths << Rails.root.join('vendor', 'assets', 'components')

_require_ the bootstrap dependency

*= require bootstrap-sass-official

The problem is in _glyphicons file the lines where we specify the dependency with the font files I need to change it to because it's giving me error.

//= depend_on "bootstrap-sass-official/assets/fonts/bootstrap/glyphicons-halflings-regular.eot"
//= depend_on "bootstrap-sass-official/assets/fonts/bootstrap/glyphicons-halflings-regular.svg"
//= depend_on "bootstrap-sass-official/assets/fonts/bootstrap/glyphicons-halflings-regular.ttf"
//= depend_on "bootstrap-sass-official/assets/fonts/bootstrap/glyphicons-halflings-regular.woff"

I don't like the idea of go to the bower files and change it, that's pretty bad in my opinion. What can I do? for fix this problem

@yordis
Copy link
Author

yordis commented Aug 22, 2014

@glebm can you help me with this please?

@glebm
Copy link
Member

glebm commented Aug 22, 2014

For you app, you can simply add bootstrap-sass-official/assets/fonts to the load path (#592).

config.assets.paths << Rails.root.join(*%w(assets components bootstrap-sass-official assets fonts)

A better solution would be improve Sprockets with support for relative paths in depend_on, so bootstrap-sass can depend_on ../fonts/bootstrap.... Last time I checked relative paths refused to work with depend_on, but this was a few months ago.

@yordis
Copy link
Author

yordis commented Aug 22, 2014

yes I am looking for something like improve the sprockets I don't want to add the bootstrap font path to my assets or something related to that.
I going to change the _glyphicons then and put the relative path. Thank very much @glebm

glebm added a commit to glebm/bootstrap-sass that referenced this issue Aug 23, 2014
glebm added a commit that referenced this issue Aug 24, 2014
@yordis
Copy link
Author

yordis commented Aug 24, 2014

@glebm why did you revert the commit?

@glebm
Copy link
Member

glebm commented Aug 24, 2014

Because it does not work, see rails/sass-rails#241

glebm added a commit that referenced this issue Sep 6, 2014
Sprockets does not require depend_on for our use case since v2.1.4
Drop the directives, and instruct Rails users to use sprockets-rails
v2.1.4+.

Profit: Bower package can now be used from Rails

Related issues: #592, #689
@glebm
Copy link
Member

glebm commented Sep 6, 2014

Please try out the lastest next branch, see the commit for details.

@glebm glebm added this to the v3.2.1 milestone Sep 15, 2014
@glebm
Copy link
Member

glebm commented Sep 15, 2014

To do: add Readme section on using the Bower package with Rails.

@Ross-Hunter
Copy link

This issue also affects middleman (and I imagine anything else that uses sprockets).

I had to similarly tell sprockets about the font load path. In my case I wanted to load all the fonts so I have a little bit of heavy-handed loading going on here in config.rb

after_configuration do
  @bower_config = JSON.parse(IO.read("#{root}/.bowerrc"))
  Dir.glob(File.join("#{root}", @bower_config["directory"], "**/*", "fonts")) do |f|
    sprockets.append_path f
  end
  sprockets.append_path File.join "#{root}", @bower_config["directory"]
end

This appears to work for me.

@glebm
Copy link
Member

glebm commented Oct 17, 2014

Relative path resolution in font-url does not work with paths relative to the partial in Sass + Sprockets. As an alternative to modifying the load path, you can try changing $icon-font-path:

$icon-font-path: "bootstrap-sass-official/assets/fonts/bootstrap/";

@glebm glebm modified the milestones: v3.2.1, v3.3.0 Oct 28, 2014
@glebm
Copy link
Member

glebm commented Oct 29, 2014

Released in v3.3.0

@glebm glebm closed this as completed Oct 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants