Skip to content
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

Can't find stylesheet to import: @import "font-awesome" #59

Open
dima4p opened this issue May 14, 2024 · 4 comments
Open

Can't find stylesheet to import: @import "font-awesome" #59

dima4p opened this issue May 14, 2024 · 4 comments

Comments

@dima4p
Copy link

dima4p commented May 14, 2024

I have met a problem to use the gem font-awesome-rails.

The command rails dartsass:build produces an error.

Error: Can't find stylesheet to import.
  ╷
2 │ @import "font-awesome"
  │         ^^^^^^^^^^^^^^
  ╵
  app/assets/stylesheets/application.scss 2:9  root stylesheet
bin/rails aborted!
Command failed with exit 65: /usr/local/rvm/gems/ruby-3.2.3@tv/gems/dartsass-rails-0.5.0/lib/tasks/../../exe/dartsass

I suppose the problem is that the file to be included with @import "font-awesome" from
font-awesome-rails-4.7.0.8/app/assets/stylesheets/font-awesome.css.erb') is of the format .erb and therefore can not be parsed:

$ bec
Loading development environment (Rails 7.2.0.alpha)
3.2.3 :001 > require 'sass-embedded'
 => true
3.2.3 :002 > Sass.compile('/usr/local/rvm/gems/ruby-3.2.3@tv/gems/font-awesome-rails-4.7.0.8/app/assets/stylesheets/font-awesome.css.erb')
Error: expected "(".
   ╷
14 │   src: url('<%= font_path('fontawesome-webfont.eot') %>');
   │                                                   ^
   ╵
  ../../../../font-awesome-rails-4.7.0.8/app/assets/stylesheets/font-awesome.css.erb 14:51  root stylesheet

I do not know, of which gem is the bug. The candidates are:

  • dartsass-rails
  • sass-embedded
  • font-awesome-rails

The whole project that demonstrates the bug is here.

@b-nik
Copy link

b-nik commented May 14, 2024

I'm using this gem personally: https://github.com/FortAwesome/font-awesome-sass

And I also had to set the font path variable when importing it:

@use "font-awesome" with (
  $fa-font-path: "font-awesome"
);

@dima4p
Copy link
Author

dima4p commented May 14, 2024

And I also had to set the font path variable when importing it:

@use "font-awesome" with (
  $fa-font-path: "font-awesome"
);

Thank you very much. But I can not understand where the code above should be placed?
I got the message:

Error: This variable was not declared with !default in the @used module.
  ╷
3 │   $fa-font-path: "font-awesome"
  │   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵

@ntkme
Copy link
Contributor

ntkme commented Sep 4, 2024

There is no support for .erb with dartsass-rails. If your sass has any .erb dependency, you need to use dartsass-sprockets or sassc-rails + sassc-embedded, instead of dartsass-rails.

@dima4p
Copy link
Author

dima4p commented Sep 5, 2024

There is no support for .erb with dartsass-rails. If your sass has any .erb dependency, you need to use dartsass-sprockets or sassc-rails + sassc-embedded, instead of dartsass-rails.

With my patch dima4p/font-awesome-sass I use font-awesome with dartsass-rails

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants