保护不编译所有SCSS样式表

时间:2013-03-31 23:00:46

标签: sass guard css-preprocessor

如果你有一个使用sass @import导入其他的包装样式表,并且当使用guard来监视更改时,如果你只更改一个导入的文件,它将不会自动编译包装样式表。例如:

/* This is viewports.scss, which must compile into viewports.css */
@media only screen and (min-width: 480px) {
    @import "480.scss";
}

@media only screen and (min-width: 768px) {
    @import "768.scss";
}

@media only screen and (min-width: 1024px) {
    @import "1024.scss";
} 

当修改例如480up.scss时,它按预期编译为480up.css,但是Guard没有将其导入到viewports.css ,似乎无法识别依赖项。当您想在一个已编译的css中实现响应,但在单独的scss文件中编写代码时,此用法很重要。

如果你只是使用sass命令,你有预期的行为,如果你使用Guard,不是。

是否有一些解决方法?我需要配置一些额外的东西吗?

1 个答案:

答案 0 :(得分:0)

Guard对文件的依赖性一无所知,只是提供了轻松处理文件系统修改事件的基础。我看到有两个用于sass的Guard插件:

我选择了后卫,因为它是积极维护的。当我阅读文档时,我看到了

:smart_partials => true # Causes guard-sass to do dependency resolution and only
                        # recompile the files that need it when you update partials.
                        # If not on, then guard-sass will update all files when a
                        # partial is changed.
                        # default: false

所以看起来看守已经应该正确处理你的情况了。

相关问题