-
Notifications
You must be signed in to change notification settings - Fork 19
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
Use SASS's asset-url helper instead of font-url #6
Conversation
Don't mind my dumb. I was not compiling my assets for production when testing production caching. No fork/PR needed. |
no problem :) |
Hi @iwe, I don't understand why @timothyrobb closed this ticket. I'm having the same problem. In production, the fonts may digest to something like I think we should use |
can you confirm that using |
Yes. My problem fixed by creating a entypo-fonts.css.scss file with the code that timothyrobb provided. I'm using rails (4.0.1) and sass (3.2.12). |
@guangnan As I said, when I was compiling my assets, I didn't compile them using the correct environment. Not compiling your assets for production when running in production is generally A Bad Thing to do. |
@timothyrobb thanks for the help, in fact I tested it with |
@lwe Yeah, that sounds like a great idea :) Sorry for all the hassle. It's such a simple mistake to make too. Goddamn Rails and it's environment fragmentation. |
I'm using the correct environment. My problem is not related to environment. If you have assets digest set to true, then not using
|
@guangnan I cannot confirm this actually (checked it on one of our rails apps) and we are using the same sass/rails version. Could you create a sample rails app where the issue is present? @timothyrobb haha, no worries there, the asset pipeline sometimes is indeed a very frustrating experience - or just a bit too much of a blackbox/different variables that come into play etc. etc. |
@guangnan Just out of curiosity, did you try compiling with the production env set? |
Test 1: running asset precompile without RAILS_ENV variable rm -rf public/assets
rake assets:precompile the application-....css contains URLs without digests -> fail, even with @font-face {
font-family: 'entypo';
src: url(/assets/entypo.eot);
src: url(/assets/entypo.eot?#iefix) format("embedded-opentype"), url(/assets/entypo.woff) format("woff"), url(/assets/entypo.ttf) format("truetype"), url(/assets/entypo.svg#entypo) format("svg");
font-weight: normal;
font-style: normal;
} Test 2: running precompile with RAILS_ENV rm -rf public/assets
RAILS_ENV=production rake assets:precompile success, the application-....csss containts URLs with digests, actually it also contains digests with @charset "UTF-8";@font-face{font-family:'entypo';src:url(/assets/entypo-4a74efb3ed26fe0c57556bcc0b7e871f.eot);src:url(/assets/entypo-4a74efb3ed26fe0c57556bcc0b7e871f.eot?#iefix) format("embedded-opentype"),url(/assets/entypo-ea098060e3c759d8a165d73d4e8955b1.woff) format("woff"),url(/assets/entypo-6a0567ea4a7430cb28b96bf7b002142c.ttf) format("truetype"),url(/assets/entypo-cddf3f136885fb2eccb1d6cc8a015583.svg#entypo) format("svg");font-weight:normal;font-style:normal} |
Okay. I start to know what's going on here. You guys are been right. Thanks! By change Thanks... |
No problem, FYI added a troubleshooting section, feel free to improve https://github.com/lwe/entypo-rails#troubleshooting |
font-url will only generate paths to the "assets/" directory, however it will not include any cache-busting timestamps from the asset pipeline.
SASS has the asset-url helper to do just this.
See:
http://stackoverflow.com/questions/8334573/asset-path-in-scss-file-rails#answer-8663533
http://rubydoc.info/github/petebrowne/sprockets-sass/master/Sprockets/Sass/Functions#asset_url-instance_method