我正在尝试使用 Compass font-face mixin,其中包含
*.eot?iefix
我的 app/assets/fonts 包含所有需要的字体类型,包括 .eot。
当我尝试运行 assets:precompile 任务失败时说: webfont.eot?iefix is not precompiled
你知道这个问题的可能解决方案吗?
如果我有 config.assets.compile = true,它运行没有错误,但据我所知,最好不要在生产中使用它。
我正在尝试使用 Compass font-face mixin,其中包含
*.eot?iefix
我的 app/assets/fonts 包含所有需要的字体类型,包括 .eot。
当我尝试运行 assets:precompile 任务失败时说: webfont.eot?iefix is not precompiled
你知道这个问题的可能解决方案吗?
如果我有 config.assets.compile = true,它运行没有错误,但据我所知,最好不要在生产中使用它。
你也可以用纯Scss做到这一点:
@font-face {
font-family: 'DroidSans';
src: url(font-path('DroidSans-webfont.eot'));
src: url(font-path('DroidSans-webfont.eot') + '?#iefix') format('embedded-opentype'),
url(font-path('DroidSans-webfont.woff')) format('woff'),
url(font-path('DroidSans-webfont.ttf')) format('truetype'),
url(font-path('DroidSans-webfont.svg') + '#DroidSansRegular') format('svg');
font-weight: normal;
font-style: normal;
}
我刚刚用一点(受支持的)hack 解决了这个问题。
我创建了一个新的 css 文件font.css.erb
并放置@import "font"
在@font-face
声明的位置。
@font-face {
font-family: 'SketchBlockBold';
src: font_url('font/sketch_block-webfont.eot');
src: url('<%= asset_path('font/sketch_block-webfont.eot')+"?#iefix" %>') format('embedded-opentype'),
font_url('font/sketch_block-webfont.woff') format('woff'),
font_url('font/sketch_block-webfont.ttf') format('truetype'),
url('<%= asset_path('font/sketch_block-webfont.svg')+"#SketchBlockBold" %>') format('svg');
font-weight: normal;
font-style: normal;
}
注意资产路径的使用,以及特殊文件结尾的连接。
似乎是一个已知问题https://github.com/rails/rails/issues/3045 目前使用 config.assets.compile = true。