Rails 3.1 / Compass / sprockets-两次生成CSS

问题描述

| 使用指南针rails31分支和sass-rails的github版本:
gem \"sass-rails\",:git => \"https://github.com/rails/sass-rails.git\"
gem \"compass\",:git => \"https://github.com/chriseppstein/compass.git\",:branch => \"rails31\"
我创建了一个部分(_base.css.scss),其中包含蓝图/重置和蓝图印刷术的导入。我还有一个screen.css.scss文件,其中包括我的基本部分。 当Rails将其编译到application.css中时,我看到两次重置和排版CSS。 样式表/application.css.scss
/*
 * This is a manifest file that\'ll automatically include all the stylesheets available in this directory
 * and any sub-directories. 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 .
*/
样式表/部分/_base.css.scss
@import \"blueprint/reset\";
@import \"blueprint/typography\";

@include blueprint-typography;
样式表/部分/screen.css.scss
@import \"partials/_base\";

#container { @include container; }
我不太了解这里发生了什么,开始使用带导轨的指南针3.1的正确配置是什么 非常感谢您的指导!     

解决方法

        如果您正在使用
require_tree .
在application.css清单中,它将自动包含该文件所在目录中的所有文件。 在application.css清单中尝试以下方法,而不要使用@import:
/*
  *= require blueprint/src/reset
  *= require blueprint/src/typography 
  *= require_self
  *= require_tree . 
*/
另外,您可能希望将蓝图放置在供应商/资产/样式表中,而不是应用程序/供应商(其中应包含应用程序特定的代码)     ,        这是我的解决方案,也许不是应该做的方式,(我真的不知道如何使用链轮),但它似乎可行...请告诉我是否有更好的方法实现这一目标。 application.css.scss
/*
 * This is a manifest file that\'ll automatically include all the stylesheets available in this directory
 * and any sub-directories. 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 .
*/

@import \"blueprint/reset\";
@import \"blueprint/typography\";

@include blueprint-typography;
screen.css.scss
@import \"blueprint\";
@import \"partials/_base\";

#container { @include container; }
_base.css.scss
# Columns or colors variables goes here...
    ,        这可能不是您的情况,但CSS两次加载两次的一个原因是,如果您在@import语句中放置了文件扩展名(例如.css)。