Ruby on rails 通过纱线罐安装带引导装置的导轨';找不到字体
我有一个Rails 5应用程序,它带有引导,我是用Thread安装的。我做了以下工作:Ruby on rails 通过纱线罐安装带引导装置的导轨';找不到字体,ruby-on-rails,twitter-bootstrap,heroku,yarnpkg,Ruby On Rails,Twitter Bootstrap,Heroku,Yarnpkg,我有一个Rails 5应用程序,它带有引导,我是用Thread安装的。我做了以下工作: 纱线添加引导程序 bootstrap@^3.3.7: version "3.3.7" resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-3.3.7.tgz#5a389394549f23330875a3b150656574f8a9eb71" 关于application.css *= require bootstrap/dist/
纱线添加引导程序
bootstrap@^3.3.7:
version "3.3.7"
resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-3.3.7.tgz#5a389394549f23330875a3b150656574f8a9eb71"
关于application.css
*= require bootstrap/dist/css/bootstrap
关于application.js
//= require bootstrap/dist/js/bootstrap
//= require rails-ujs
//= require @fnando/sparkline/dist/sparkline
//= require_tree .
关于assets.rb
Rails.application.config.assets.paths << Rails.root.join('node_modules')
Rails.application.config.assets.paths << Rails.root.join('node_modules/bootstrap/dist/fonts')
Rails.application.config.assets.precompile << %r{node_modules/bootstrap/dist/fonts/[\w-]+\.(?:eot|svg|ttf|woff2?)$}
我尝试添加
$icon字体路径:“node\u modules/bootstrap/dist/font”代码>也适用于我的SCS,但这也不能解决字体路径的问题。
用于font awesome节点\u模块/font awesome/SCSS/\u路径的SCSS文件。SCSS
具有以下功能:
@font-face {
font-family: 'FontAwesome';
src: url('#{$fa-font-path}/fontawesome-webfont.eot?v=#{$fa-version}');
...
}
但它应该是字体url(..)而不是url(..),因此字体文件将预编译并存储在公共/资产中
覆盖application.scss中的字体路径:
$fa-font-path:"font-awesome/fonts";
@import 'font-awesome/scss/font-awesome';
@font-face {
font-family: 'FontAwesome';
src: font-url('#{$fa-font-path}/fontawesome-webfont.eot?v=#{$fa-version}');
src: font-url('#{$fa-font-path}/fontawesome-webfont.eot?#iefix&v=#{$fa-version}') format('embedded-opentype'),
font-url('#{$fa-font-path}/fontawesome-webfont.woff2?v=#{$fa-version}') format('woff2'),
font-url('#{$fa-font-path}/fontawesome-webfont.woff?v=#{$fa-version}') format('woff'),
font-url('#{$fa-font-path}/fontawesome-webfont.ttf?v=#{$fa-version}') format('truetype'),
font-url('#{$fa-font-path}/fontawesome-webfont.svg?v=#{$fa-version}#fontawesomeregular') format('svg');
// src: url('#{$fa-font-path}/FontAwesome.otf') format('opentype'); // used when developing fonts
font-weight: normal;
font-style: normal;
}
运行rake-assets:precompile
,您应该会在public/assets/font-awesome/fonts
中看到字体文件,其中包含摘要文件名
编译的CSS应该访问Rails资源中的字体文件:
@font-face{
font-family:'FontAwesome';
src:url(/assets/font-awesome/fonts/fontawesome-webfont-7bfcab6db99...979.eot?v=4.7.0)
@font-face{
font-family:'FontAwesome';
src:url(/assets/font-awesome/fonts/fontawesome-webfont-7bfcab6db99...979.eot?v=4.7.0)