Rails compiler error with fontawesome when deploy to heroku

老子叫甜甜 提交于 2019-12-12 09:14:22

问题


I got an error message when I try to push my Rails project to Heroku. I am using Fontawesome, it works prefectly in local environment but just won't push to Heroku.

Running: rake assets:precompile I, [2016-03-22T05:59:25.096354 #366] INFO -- : Writing /tmp/build_3e31f1bb8b828cb787890706e9ec589b/public/assets/FontAwesome-0d34da07e5cbcb4ff087b397966a9f9ffb4d6ed7c7060568565203c02f3fee11.otf I, [2016-03-22T05:59:25.099701 #366] INFO -- : Writing /tmp/build_3e31f1bb8b828cb787890706e9ec589b/public/assets/fontawesome-webfont-e511891d3e01b0b27aed51a219ced5119e2c3d0460465af8242e9bff4cb61b77.eot

rake aborted! Sass::SyntaxError: Invalid CSS after "...orm-group::not(": expected pseudo_expr, was ":first-child)" (sass):9108

/tmp/build_3e31f1bb8b828cb787890706e9ec589b/vendor/bundle/ruby/2.2.0/gems/sprockets-rails-3.0.4/lib/sprockets/rails/task.rb:67:in block (2 levels) in define' Tasks: TOP => assets:precompile (See full trace by running task with --trace) ! ! Precompiling assets failed. ! ! Push rejected, failed to compile Ruby app

Here is my gemfile:

source 'https://rubygems.org'

gem 'sprockets', '~> 3.0'
gem 'rails', '4.2.6'
gem 'pg', '~> 0.15'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc

group :development, :test do 
 gem 'byebug'
end

group :development do
  gem 'web-console', '~> 2.0'
  gem 'spring'
end

回答1:


Put this gem in your gem file:

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

Then import these in your application.scss

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

Then bundle install the gem using console.

Then(important) use rake in console to clean and precompile your assets before push to Heroku

rake assets:clean
rake assets:precompile

Now your assets should be compile correctly when you push.




回答2:


might be easier to use: gem 'font_awesome5_rails'



来源:https://stackoverflow.com/questions/36147328/rails-compiler-error-with-fontawesome-when-deploy-to-heroku

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