seyhunak / twitter-bootstrap-rails

Twitter Bootstrap for Rails 6.0, Rails 5 - Rails 4.x Asset Pipeline
https://github.com/seyhunak/twitter-bootstrap-rails
4.49k stars 997 forks source link

rake assets:precompile error in Rails (FontAwesome) #292

Closed melekes closed 12 years ago

melekes commented 12 years ago

Hello,

I've just updated your gem and run rake assets:precompile and this is what I've got during deploy:

Invalid CSS after "...e.eot);src:url(": expected expression (e.g. fr, 2n+1), was "/assets/"/asset..."

I think, the case is in vendor/toolkit/fontawesome.less:

@font-face {
  font-family: 'FontAwesome';
  src: asset-url(@fontAwesomeEotPath);
  src: asset-url("@{fontAwesomeEotPath}?#iefix") format('embedded-opentype'),
    asset-url(@fontAwesomeWoffPath) format('woff'),
    asset-url(@fontAwesomeTtfPath) format('truetype'),
    asset-url('@{fontAwesomeSvgPath}#FontAwesome') format('svg');
  ...
}

The result of the code above is:

@font-face {
   font-family: 'FontAwesome';
   src: url(/assets/fontawesome-webfont.eot);
   src: url(/assets/"/assets/fontawesome-webfont.eot"?#iefix) format('embedded-opentype'), url(/assets/fontawesome-      webfont.woff) format('woff'), url(/assets/fontawesome-webfont.ttf) format('truetype'), url(/assets/"/assets/fontawesome-webfont.svg"#FontAwesome) format('svg');
  ...
}

rails: 3.2.3 twitter-bootstrap-rails: 2.1.0

luizkowalski commented 12 years ago

same here, but i think this is related to #290

luizkowalski commented 12 years ago

I've just commented out these lines and worked, but now, I'm without fontawesome

// Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines)
//@fontAwesomeEotPath: asset-path('fontawesome-webfont.eot');
//@fontAwesomeWoffPath: asset-path('fontawesome-webfont.woff');
//@fontAwesomeTtfPath: asset-path('fontawesome-webfont.ttf');
//@fontAwesomeSvgzPath: asset-path('fontawesome-webfont.svgz');
//@fontAwesomeSvgPath: asset-path('fontawesome-webfont.svg');

// Font Awesome
//@import "fontawesome";
jgrevich commented 12 years ago

That works, although you can still use the webfont. Remove the svgz version and use absolute paths instead of the asset-path helper. See issue #290 for a more thorough response.

luizkowalski commented 12 years ago

can you provide some example?...i didn't got it :\

jgrevich commented 12 years ago

No problem:

Copy from the new bootstrap_and_overrides.css.less to resolve the issue. Specifically, you need to remove the svgz font path variable and use absolute paths instead of the asset-path helper (see below):

// Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines)
// Note: If you use asset_path() here, your compiled boostrap_and_overrides.css will not 
// have the proper paths. So for now we use the absolute path.
@fontAwesomeEotPath: '/assets/fontawesome-webfont.eot';
@fontAwesomeWoffPath: '/assets/fontawesome-webfont.woff';
@fontAwesomeTtfPath: '/assets/fontawesome-webfont.ttf';
@fontAwesomeSvgPath: '/assets/fontawesome-webfont.svg';
luizkowalski commented 12 years ago

thank you :D

jgrevich commented 12 years ago

@luizkowalski, my pleasure. Cheers!

melekes commented 12 years ago

Thanks @jgrevich. I think this could be closed now.

jgrevich commented 12 years ago

@akalyaev anytime. I believe we can also close issue #290 as it is a duplicate of this issue.

bradly commented 12 years ago

@akalyaev Was this actually fixed or do we just have a work-around? If it is still an issue I may have time to work on a patch.

jgrevich commented 12 years ago

@bradly The error was due to people's bootstrap_and_overrides.css.less file declaring variables for the svgz version of the font that no longer exists. The generator has been updated to remove the code, but perhaps we need to improve the error message or provide better documentation for people who are upgrading.

bradly commented 12 years ago

@jgrevich That makes sense. Thanks for the clarification. I just re-ran the rails g bootstrap:install, re-added my changes, and things are working again. Thanks again!