Rails 3.1资产管道不会获取@ import'd工作表的更改 [英] Rails 3.1 asset pipeline doesn't pick up changes to @import'd sheets
问题描述
我使用 @import
'部分工作表来整理我的css / sass:
I use @import
'd partial sheets to organize my css/sass:
/app
/assets
/stylesheets
_constants.sass
_layout.sass
...
app.css.sass
app.css.sass:
@import _constants.sass
// basic styles
@import _layout.sass
@import ...
app.css.sass
有 @import
_layout.sass
的规则,它允许我在原始sass文件之前共享mixins和变量,然后再进行编译进入 app.css
app.css.sass
has an @import
rule for _layout.sass
, which allows me to share mixins and variables amongst the raw sass files before they're complied down into app.css
问题是Rails无法识别对的更改@import
'd partials( _layout.sass
)并且不会重新生成 app.css
直到我对实际的 app.css.sass
文件本身进行更改。这大大减慢了我的工作流程,这意味着我必须在 app.css.sass
中添加/删除空白行以查看更改。从来没有在3.0中遇到过这个问题。
The problem is that Rails doesn't recognize changes to the @import
'd partials (_layout.sass
) and won't regenerate app.css
until I make a change to the actual app.css.sass
file itself. This dramatically slows down my workflow and means I have to add/remove blank lines from app.css.sass
to see changes. Never had this problem in 3.0.
有没有办法强制sass资产在开发中的每个服务器请求上重新生成?
Is there a way of forcing sass assets to regenerate on every server request in development?
推荐答案
使用 depend_on
指令可以满足您的要求。这使得给定文件成为基本文件的依赖项(因此当依赖项更改时会重新生成基本文件),但不会将其包含在包中。
Using a depend_on
directive may do what you require. This makes the given file a dependency of the base file (so the base file is regenerated when the dependency changes), but doesn't include it in the bundle.
For例如:
/*
*= depend_on _layout.sass
*= depend_on _constants.sass
*/
@import _layout.sass
@import _constants.sass
请参阅此 sass和sprockets博客文章以及 sprockets文档(特别是指令部分)。
See this sass and sprockets blog post as well as the sprockets documentation (especially the directives section).
这篇关于Rails 3.1资产管道不会获取@ import'd工作表的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!