【问题标题】:Rails precompile error - too hard to find which file is causing the errorRails 预编译错误 - 很难找到导致错误的文件
【发布时间】:2014-07-09 15:01:00
【问题描述】:

我做了RAILS_ENV=production rake assets:clean; RAILS_ENV=production rake assets:precompile --trace

我得到了

rake aborted!
Sass::SyntaxError: Invalid CSS after "}": expected selector or at-rule, was "}"
  (in /Users/hsu-wei-cheng/Dropbox/Rails/dqa_dev_server/vendor/themes/lenord-single-page-theme/application.css)
(sass):7322

但是在lenord-single-page-theme/application.css

/*
 *= require_self
 *= require_tree .
 */

我注释掉了所有config.assets.precompile

  # Precompile additional assets.
  # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
  #config.assets.precompile += %w( bootstrap.css )
  # config.assets.precompile += %w( vendor/themes/* )
  #config.assets.precompile += %w( vendor/themes/**/application.js )
  #config.assets.precompile += %w( vendor/themes/**/application.css )
  # config.assets.precompile += %w[*.png *.jpg *.jpeg *.gif] 

  # Precompile *all* assets, except those that start with underscore
  #config.assets.precompile << /(^[^_\/]|\/[^_])[^\/]*$/

如何获得有关错误的更多信息?

【问题讨论】:

  • 您的 scss 文件中某处存在语法错误。
  • 是的,当有几十个文件时,这个错误是没有帮助的。也许可以使用一个文件夹并对其中的每个文件进行 css 检查?

标签: ruby-on-rails ruby sass asset-pipeline


【解决方案1】:

如果您的问题是 SASS 代码中某处的语法错误,为什么不使用 SASS 调试器?

网上有好几个。例如 Chrome 的两个(可以与 TextMate 集成):Sass InspectorSass Sleuth

【讨论】:

    【解决方案2】:

    我之前遇到过这个错误,它让我发疯,因为我找不到语法错误。

    但后来我renamed all my .css files to be .scss 并且所有错误都消失了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-02
      • 2021-09-06
      • 2012-08-08
      • 2012-11-20
      • 2015-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多