Rails 3.1资产管道中SCSS文件中的循环依赖项错误 [英] Circular dependency error in SCSS file in Rails 3.1 asset pipeline

查看:166
本文介绍了Rails 3.1资产管道中SCSS文件中的循环依赖项错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Assets/stylesheets目录中有 application.css.scss ,以及许多控制器特定的scss文件.

I've got application.css.scss in my assets/stylesheets directory, along with a number of controller-specific scss files.

application.css.scss文件具有

The application.css.scss file has

*= require_self
*= require_tree .

我遵循这些指令有一些普通的scss.当两个require语句都启用时,我得到"/app/assets/stylesheets/application.css.scss已经是必需的." (没有 application.css ,我已经仔细检查过了.)

And I have some ordinary scss following these directives. When both require statements are enabled, I get "/app/assets/stylesheets/application.css.scss has already been required." (There is no application.css, I've double-checked.)

注释 * require_tree.* 行可消除该错误,但显然不包含该目录中的其他scss文件.解决方法是分别需要这些文件,但这不是长期解决方案.(取出require_self行也不能消除该错误.)

Commenting out the *require_tree .* line eliminates the error, but obviously doesn't include the other scss files in the directory. The workaround is to require these files individually but that's not the long term solution. (Taking out the require_self line doesn't eliminate the error, either.)

我曾经以为Rails足够聪明来解决这个问题-我感觉自己错过了一些显而易见的事情.有想法吗?

I had thought Rails was smart enough to resolve this -- I have a feeling I've missed something obvious. Thoughts?

推荐答案

您说的它不包括其他scss文件.还有哪些其他的scss/css文件,您是否至少在其中一个文件中插入了 * = require_tree.?这将再次加载application.css文件.我有同样的问题.我刚刚从所有其他css/scss文件中删除了这些行.

You say it doesn't include the other scss files. What are the other scss/css files and did you inserted the *= require_tree . in at least one of them? This would load the application.css file again. I had the same problem. I just removed these lines from all other css/scss files.

这篇关于Rails 3.1资产管道中SCSS文件中的循环依赖项错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆