rake assets:precompile throws Sass :: SyntaxError:“* /”之后的CSS无效

我希望这不是一个重复的问题; 我在SO上尝试了其他解决方案,没有任何效果

当我的应用程序推送到Heroku时,推送失败,因为application.css无法编译。

我的终端输出:

Running: rake assets:precompile rake aborted! Sass::SyntaxError: Invalid CSS after " */": expected selector, was "@font-face" (in /tmp/build_17e92975-ae8d-446f-8678-110eeeccfb64/app/assets/stylesheets/adminsite/application.css) (sass):1845 

尝试解决方案

我搜索并删除了../stylesheets/adminsite/目录中@ font-face之前的每个“* /”实例。 同样的问题和结果。

我试过设置:

  config.assets.compile = true 

……同样的问题

编辑

这是我的application.css(不是应用程序级别1,而是adminsite目录中失败的那个)

 /* * This is a manifest file that'll be compiled into application.css, which will include all the files * listed below. * * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. * * You're free to add application-wide styles to this file and they'll appear at the top of the * compiled file, but it's generally better to create a new file per style scope. * *= require jquery.ui.all *= require_self *= require normalize *= require ./global/plugins/bootstrap/css/bootstrap *= require ./global/plugins/uniform/css/uniform.default *= require ./global/plugins/bootstrap-switch/css/bootstrap-switch *= require ./global/css/components *= require ./global/css/plugins *= require ./global/plugins/simple-line-icons/simple-line-icons *= require ./admin/layout/css/layout *= require ./admin/layout/css/themes/light2 *= require ./admin/layout/css/custom */ 

通过删除和重新整理,我发现了

 *= require ./global/plugins/font-awesome/scss/font-awesome 

从该列表的底部开始的是3,导致它失败。 我现在可以在本地运行了

 rake assets:precompile --trace RAILS_ENV=production 

但是我无法使用

 git push herokunb newbeta:master 

解决了:

这是字体真棒CSS。 删除它需要修复它。 这个问题似乎没有解决,只是由于我自己的git错误。

即使你找到了修复它的方法,我也会分享我的解决方案,因为我遇到了同样的问题而且调试起来有点困难。

您可能正在使用rails 3.2, sass-rails 3.2和font-awesome-sass 4.1。

事实certificate, rails 3.2使用sass-rails 3.2.6 ,这取决于sass > = 3.1 。 但是,看起来sass 3.1与font-awesome 4.1不兼容,所以我明确地设置sass gem在我的Gemfile上使用3.2版。

 gem 'sass-rails', '~> 3.2.6' gem 'sass', '~> 3.2.0' 

希望这有助于某人! ;)

破坏事物的文件是字体真棒CSS。 从application.css的“require”行中删除它允许预编译工作。

这样做的方法是首先删除所有预编译需求字段,显示它将编译,然后慢慢添加需要字段以查看它中断的位置。

(感谢所有帮助解决这个问题的人。)

对我来说,我忘了在class级登录前添加#。

它应该是

 #sign-in (your code) 

我是rails的新手,在推送到heroku时遇到了类似的问题。 一位朋友看了我的application.css文件,注意到我有

*= require bootstrap

*= require bootstrap-datetimepicker

低于*/

删除它们让我成功推动。

我也遇到了类似的问题,偶然发现了这个问题。 对我来说,我离开了我的一个CSS语句的结尾。 添加它,我在几分钟内恢复。

解决此问题的另一种方法是明确告诉资产管道使用资产的css版本而不是scss版本。 例如,如果您在application.scss中导入.scss文件,如下所示:

 @import "angular-material"; # this will use scss version of the asset 

您也可以告诉它使用css版本,如下所示:

 @import "angular-material.css"; # this will use the css version 

大多数供应商都提供scss和css版本,因此依赖css版本的资产非常有用,尤其是在使用供应商资产时。 记住一切都将是预编译并最终变得丑化,所以你使用scss或css它们都会变得相同。