2

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

使用带有 SASS 的 Rails 3.2。我有一个配置部分,它定义了一堆我想在我的 scss 文件中使用的 SASS 变量。根据本指南,我先导入configuration,然后bonus。但是,我一直在 bonus.css.scss 中得到Sass::SyntaxError说法。Undefined variable: "$darkRed"我究竟做错了什么?

应用程序.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;

奖金.css.scss

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

2 回答 2

2

所以我碰到了这个,想给出一个更准确的答案:

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

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

就这么简单,虽然有时很容易通过!

于 2014-08-07T20:14:31.697 回答
-4

您在以下位置导入名称错误的 scss 文件application.css.scss

代替:@import "configuration";

和:@import "_configuration";

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

于 2012-11-10T15:27:58.480 回答