gpt4 book ai didi

ruby-on-rails - Rails : Installing font-awesome in Rails 6. 0.0-rc1 与 webpacker 和 yarn

转载 作者:行者123 更新时间:2023-12-01 07:17:19 25 4
gpt4 key购买 nike

我正在尝试通过 yarn 安装 FontAwesome通过做yarn add @fontawesome/fontawesome-free ,然后将其添加到我的 application.scss :

$fa-font-path: '~@fortawesome/fontawesome-free-webfonts/webfonts';
@import '~@fortawesome/fontawesome-free-webfonts/scss/fontawesome';
@import '~@fortawesome/fontawesome-free-webfonts/scss/fa-solid';

我已经尝试在 application.scss 中写了几件事我通过互联网看到的,但它们都不起作用,因为我收到以下错误:
Sass::SyntaxError in Pages#index
Showing /Users/foo/dev/project/app/views/layouts/application.html.erb where line #9 raised:

File to import not found or unreadable: ~@fortawesome/fontawesome-free-webfonts/scss/fontawesome.
Load paths:
/Users/foo/dev/project/app/assets/images
/Users/foo/dev/project/app/assets/javascripts
/Users/foo/dev/project/app/assets/stylesheets
/Users/foo/dev/project/vendor/bundle/ruby/2.5.0/gems/coffee-rails-5.0.0/lib/assets/javascripts
/Users/foo/dev/project/vendor/bundle/ruby/2.5.0/gems/actioncable-6.0.0.rc1/app/assets/javascripts
/Users/foo/dev/project/vendor/bundle/ruby/2.5.0/gems/activestorage-6.0.0.rc1/app/assets/javascripts
/Users/foo/dev/project/vendor/bundle/ruby/2.5.0/gems/actionview-6.0.0.rc1/lib/assets/compiled
/Users/foo/dev/project/node_modules

非常感谢您的帮助!

最佳答案

您需要删除 ~在您的导入开始时签名,它应该可以正常工作。

它应该是这样的:

$fa-font-path: '@fortawesome/fontawesome-free-webfonts/webfonts';
@import '@fortawesome/fontawesome-free-webfonts/scss/fontawesome';
@import '@fortawesome/fontawesome-free-webfonts/scss/fa-solid';

希望能帮助到你 :)

关于ruby-on-rails - Rails : Installing font-awesome in Rails 6. 0.0-rc1 与 webpacker 和 yarn ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55989717/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com