【问题标题】:Precompiling assets failing when including boostrap包含引导程序时预编译资产失败
【发布时间】:2020-04-20 03:01:00
【问题描述】:

我正在尝试在生产环境中预编译资产。但是在包含以下文件时出现错误。

bootstrap_style.sass

@import bootstrap
a
  color: #6b9029

application.css

/*
*= require_self
*= require jquery-ui
*= require prettyPhoto.css
*= require prettyLoader.css
*= require prettyPopin.css
*= require prettyPhoto.css
*= require sass/main
*= require sass/master
*= require sass/ie
*= require sass/ie8
*= require sass/buy_now
*= require sass/ssl_seal
*= require font-awesome
*/

/*
TODO: I had to remove the site report from the main import here.
This will need to be added back and loaded only on the site report page only
or figure out why the styles are conflicting with the main layout
require sass/site_report
*/

错误

rake aborted!
Sass::SyntaxError: Invalid CSS after "...lor}: #{$value}": expected "{", was ";"
/var/lib/gems/2.6.0/gems/bootstrap-4.4.1/assets/stylesheets/bootstrap/_root.scss:5

更新错误

SassC::SyntaxError: Error: Undefined operation: "prefix-usage(browser-prefixes(browsers()), css-boxshadow, (full-support: true), (partial-support: true)) gt 0.1".
        on line 324:7 of ../var/lib/gems/2.6.0/gems/compass-core-1.0.3/stylesheets/compass/_support.scss, in function `use-prefix`
        from line 208:33 of ../var/lib/gems/2.6.0/gems/compass-core-1.0.3/stylesheets/compass/_support.scss, in function `prefixes-for-capability`
        from line 218:40 of ../var/lib/gems/2.6.0/gems/compass-core-1.0.3/stylesheets/compass/_support.scss, in mixin `with-each-prefix`
        from line 360:12 of ../var/lib/gems/2.6.0/gems/compass-core-1.0.3/stylesheets/compass/_support.scss, in mixin `prefixed-properties`
        from line 43:12 of ../var/lib/gems/2.6.0/gems/compass-core-1.0.3/stylesheets/compass/css3/_box-shadow.scss, in mixin `box-shadow`
        from line 3902:12 of app/assets/stylesheets/sass/main.sass
>>   @if $usage > $threshold {

   ------^

ma​​in.sass

  @include box-shadow(0 0 1px 1px rgba(255, 255, 255, 0.4) inset)

【问题讨论】:

  • bootstrap_style.sass 文件的语法错误?为什么没有{ }

标签: ruby-on-rails twitter-bootstrap sass


【解决方案1】:

您可以通过运行sass -c app/assets/stylesheets 检查文件的语法。这可能会为您检测到问题。

你也可以查看这个github参考#sass

/*
 * 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, or any plugin's
 * vendor/assets/stylesheets directory 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 bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
 * files in this directory. Styles in this file should be added after the last require_* statement.
 * It is generally better to create a new file per style scope.
 *
 *= require jquery-ui
 *= require prettyPhoto.css
 *= require prettyLoader.css
 *= require prettyPopin.css
 *= require prettyPhoto.css
 *= require sass/main
 *= require sass/master
 *= require sass/ie
 *= require sass/ie8
 *= require sass/buy_now
 *= require sass/ssl_seal
 *= require font-awesome
 *= require_self
*/

【讨论】:

  • 这帮助我跟踪了一个问题。但是我现在收到此错误Error: Invalid CSS after "...ain import here": expected expression (e.g. 1px, bold), was "." on line 18 of app/assets/stylesheets/application.css Use --trace for backtrace. 我将在上面发布文件
  • 并删除该文件的注释部分会给出错误Error: Invalid CSS after "*": expected selector, was "= require_self" on line 2 of app/assets/stylesheets/application.css
  • 我编辑了我的答案内容,你现在可以试试。 :)
  • 我认为您可以使用一些在线 CSS 验证器工具来验证您的 CSS。
  • 或者试试这个帖子:- stackoverflow.com/questions/25722267/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-11-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-18
相关资源
最近更新 更多