Rails 3.1/Compass/sprockets - 生成 css 两次
使用compass 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),其中包含blueprint/reset和blueprint-typography的导入。我还有一个 screen.css.scss 文件,其中包含我的基本部分。
当 Rails 将其编译为 application.css 时,我看到重置和排版 css 两次。
stylesheets/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 .
*/
stylesheets/partials/_base.css.scss
@import "blueprint/reset";
@import "blueprint/typography";
@include blueprint-typography;
stylesheets/partials/screen.css.scss
@import "partials/_base";
#container { @include container; }
我不太明白这里发生了什么,以及开始使用带有 Rails 3.1 的指南针的正确配置是什么
非常感谢您的指导!
Using the github versions of the compass rails31 branch and sass-rails:
gem "sass-rails", :git => "https://github.com/rails/sass-rails.git"
gem "compass", :git => "https://github.com/chriseppstein/compass.git", :branch => "rails31"
I have created a partial (_base.css.scss) that contains the imports for blueprint/reset and blueprint-typography. I have also a screen.css.scss file that includes my base partial.
When rails compiles this into application.css, I'm seeing my reset and typography css twice.
stylesheets/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 .
*/
stylesheets/partials/_base.css.scss
@import "blueprint/reset";
@import "blueprint/typography";
@include blueprint-typography;
stylesheets/partials/screen.css.scss
@import "partials/_base";
#container { @include container; }
I don't really understand what is going on here, and what is the correct configuration to start using compass with rails 3.1
Thanks a lot for your guideline!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您在 application.css 清单中使用
,它将自动包含包含此文件的目录中的所有文件。
在 application.css 清单中尝试以下方法,而不是使用 @import:
另外,您可能希望将蓝图放在供应商/资产/样式表中,而不是应用程序/供应商(其中应包含应用程序特定的代码)
If you are using
in your application.css manifest it will automaticaly include all files within directory containing this file.
Try the following method in application.css manifest instead of using @import:
Also, you may want to put blueprint in vendor/assets/stylesheets instead of app/vendor (which should contain application specific code)
这是我的解决方案,它可能不是应该这样做的方式,(我真的不知道如何使用链轮)但它似乎有效......请让我知道是否有更好的方法来实现这一点。
application.css.scss
screen.css.scss
_base.css.scss
Here is my solution, it's maybe not the way It should be done, (I really don't know how to use sprockets) but it seems to work... Please let me know if there is a better way to achieve this.
application.css.scss
screen.css.scss
_base.css.scss
这可能不是您的情况,但 css 加载两次的原因之一是您在 @import 语句中添加了文件扩展名(例如 .css)。
This may not be your case, but one reason why a css gets loaded twice is if you put a file extension (e.g., .css) in your @import statement.