Sass :: SyntaxError未定义变量

时间:2012-11-10 15:11:08

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

我是Asset Pipeline的新手,所以如果我做错了,请告诉我。

将Rails 3.2与SASS一起使用。我有一个配置部分,它定义了我想在整个scss文件中使用的一堆SASS变量。根据{{​​3}},我先导入configuration,然后导入bonus。但是,我一直在bonus.css.scss中Sass::SyntaxErrorUndefined variable: "$darkRed"。我做错了什么?

application.css.scss

/*
 * 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.
*/

@import "configuration";
@import "bootstrap";
@import "bonus";

_configuration.css.scss

//colors
$darkRed: #B94A48;
$controlColor: #777;

bonus.css.scss

div.give-inline-help .help-inline
  {
  color: $darkRed;
  font-size: 15px;
  font-family: MuseoSans-300;
  padding-left: 0px;
}

2 个答案:

答案 0 :(得分:2)

所以我碰到了这个并希望给出一个更准确的答案:

非下划线命名文件下游链中的任何@import ed文件都将与Sass::SyntaxError Undefined Variable中断。

使用Sass,如果要覆盖变量,则必须确保使用不间断的下划线文件链。

这很简单,虽然有时很容易过去!

答案 1 :(得分:-3)

application.css.scss中导入名称错误的scss文件:

替换:@import "configuration";

with:@import "_configuration";

或将您的_configuration.css.scss文件重命名为configuration.css.scss