Rails Engine - File to import not found or unreadable: font-awesome

谁说胖子不能爱 提交于 2019-12-01 18:33:26

问题


I did a super simple rails app and used font-awesome with no problem. Expanding this to do the same steps in a rails engine produces the following error.

File to import not found or unreadable: font-awesome

I am unable to find a solution. If anyone has suggestions on how to make this simple rails engine work with font-awesome, I would be most appreciative.

Steps to generate the rails engine and setup font-awesome...

create the basic engine with one model class for testing

rails plugin new testeng --full --mountable 
cd testeng
bundle install
rails g scaffold book title:string desc:string
rake db:migrate

add in font-awesome

edit testeng.gemspec and add sass-rails and font-awesome gems after the rails gem is included

  s.add_dependency 'sass-rails', '~> 4.0.3'
  s.add_dependency 'font-awesome-rails'

rename application.css to application.css.scss

cd app/assets/stylesheets/testeng/
mv application.css application.css.scss

edit app/assets/stylesheets/testeng/application.css.scss and append import statement at end of file.

@import 'font-awesome';

edit app/views/testeng/books/index.html.erb and use some font-awesome icons

<h1>Listing books</h1>

<%= link_to content_tag(:i, '', :class => "fa fa-plus-circle"), new_book_path  %>

start rails server

cd <root-app-path>
bundle install
cd test/dummy
bundle install
rails s

Test in browser

http://localhost:3000/testeng/books

Get ERROR

File to import not found or unreadable: font-awesome

回答1:


Install font-awesome-sass instead:

gem 'font-awesome-sass', '~> 4.4.0'

Bundle it:

bundle install

Add the following to your application.css.scss (app/assets/stylesheets):

@import "font-awesome-sprockets";
@import "font-awesome";

As a test you can add the following line to your view to see if it works:

<%= icon('thumbs-up', 'It Worked!!!', id: 'my-icon', class: 'fa-5x') %>



回答2:


I had this issue , with the below message :

Sass::SyntaxError at /
File to import not found or unreadable: font-awesome-sprockets.
Load paths:
  /home/user/shop_app/depot2/app/assets/images
  /home/user/shop_app/depot2/app/assets/javascripts

And fixed it by updating the gem to include the version :

changed from:

 gem 'font-awesome-sass'

to:

gem 'font-awesome-sass', '~> 4.4.0'


来源:https://stackoverflow.com/questions/28356062/rails-engine-file-to-import-not-found-or-unreadable-font-awesome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!