2

I'm using sass imports to handle most of my styles for our rails 3.2 app. My application.css.scss file looks like this:

application.css

/*
 *= require_self
 *= require_tree ./vendor
 *= require admin
 */

admin.css.scss

// Reset
@import "global/reset";

// General Variables
@import "admin/general/_variables";

// Main Elements
@import "admin/general/_typography";

// Layout
@import "global/_layout";
@import "admin/general/_gridset";

// Modules
@import "admin/modules/_table";
@import "admin/modules/_forms";
@import "admin/modules/_buttons";

// Styles
@import "admin/_style-clean";
@import "admin/_style-images";

// Features
@import "admin/features/features";

Error message: Sass::SyntaxError - Undefined variable: "$body-bg". (in /var/www/apps/dev_wbs/releases/20130624191222/app/assets/stylesheets/admin/_style-clean.css.scss)

_variables.css.scss (imported) contains $body-bg, and it is referenced in _style-clean.css.scss

I originally had this in the sass syntax, but every time we push to the dev server, we get an error of Sass::SyntaxError - Undefined variable: "$body-bg". The variable is declared in the variables file, and the error comes from the _style-clean scss file. I've dropped this variable into the style-clean file, but then I get another variable error, but it refers to one in the typography file, which is above the style-clean, making me think somehow that the assets are being pre-compiled and then added.

I'd like to go back to using sass syntax, but both scss and sass throw variable errors.

All individual files are currently in the format of: _variables.css.scss.

Any help would be appreciated!

4

1 回答 1

1

资产管道依赖于application.css告诉它要包含哪些文件。将其更改为 SASS 可能不会允许它工作。

此外,您的 application.css 需要告诉 Ruby 在哪里查找文件:

/*
 * 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.
 *
 *= require_self
 *= require_tree .
 */

如果您将粘贴在问题中的代码放入像 global.css.scss 这样的新文件中并重新创建文件application.css/app/assets/stylesheets/那么您应该也可以使用上述代码和 SASS 样式进行比赛。

于 2013-06-24T19:06:01.923 回答