Sass :: SyntaxError未定义变量
我是Asset Pipeline的新手,所以如果我做错了,请告诉我。
使用Rails 3.2和SASS。 我有一个配置部分定义了一堆我想在整个scss文件中使用的SASS变量。 根据本指南 ,我首先导入configuration
,然后是bonus
。 但是,我继续在bonus.css.scss中得到一个Sass::SyntaxError
表示Undefined 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; }
您在application.css.scss
导入名称错误的scss文件:
替换: @import "configuration";
with: @import "_configuration";
或者将_configuration.css.scss
文件重命名为configuration.css.scss
所以我碰到了这个并希望给出一个更精确的答案:
非下划线命名文件下游链中的任何@import
ed文件都将破坏Sass::SyntaxError Undefined Variable
。
使用Sass,如果要覆盖变量,则必须确保使用不间断的下划线文件链。
这很简单,虽然有时很容易通过!