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
Rails can't find fonts when assets are added with Yarn #31266
Comments
I had exactly this problem today at work and was able to fix it in this way: You can use $bs-font-path: "bootstrap-sass/assets/fonts/bootstrap";
@font-face {
font-family: 'Glyphicons Halflings';
src: asset-url('#{$bs-font-path}/glyphicons-halflings-regular.eot');
src: asset-url('#{$bs-font-path}/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'),
asset-url('#{$bs-font-path}/glyphicons-halflings-regular.woff2') format('woff2'),
asset-url('#{$bs-font-path}/glyphicons-halflings-regular.woff') format('woff'),
asset-url('#{$bs-font-path}/glyphicons-halflings-regular.ttf') format('truetype'),
asset-url('#{$bs-font-path}/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
} |
I now that. Thing is I don't want to do any "workarounds", you know? I would like this to work out of the box or at least understand why it doesn't work and if there is any official way to fix if thats the case. I think that since these fonts are already in the path, they way I fixed was basically copy the |
Assuming that Rails.application.config.assets.precompile << %r{bootstrap/dist/fonts/[\w-]+\.(?:eot|svg|ttf|woff2?)$} You can test this locally running The problem that you're experiencing is that Sprockets compile digested assets to Sprockets don't do any processing/re-writing of asset URLs in CSS files so the URLs in CSS files aren't changed in any way. I'm not sure if we can do anything on Rails side to fix that. |
guess you are right...the problem is not actually Rails, but the url on the asset itself. I'll close it and evaluate your first solution, see if it fits Thanks a lot! |
A shorter alternative if you are using $icon-font-path: "bootstrap-sass/assets/fonts/bootstrap/";
@import "bootstrap-sass/assets/stylesheets/bootstrap-sprockets";
@import "bootstrap-sass/assets/stylesheets/bootstrap"; |
I'm not using bootstrap-sass...I've installed from Yarn |
Yup, I'm using Yarn too, Bootstrap team distribute |
nice to know! |
I'm on Rails 5.2.4 and adding the following line in Rails.application.config.assets.precompile << /\.(?:svg|eot|woff|woff2|ttf|otf)$/ |
I just added bootstrap to Rails using yarn
yarn add bootstrap
Locally works perfectly, but when deploying to Heroku, I can't see the assets
I tried manually copy the
fonts
folder from bootstrap, tried add this:nothing works, Rails doesn't see it
I'm using Rails 5.1.4 with MacOS High Sierra
The text was updated successfully, but these errors were encountered: