SASS minifier可以删除重复的样式吗? [英] Can the SASS minifier remove duplicate styles?
问题描述
我知道css规则相当复杂;然而,下面的css不能由优化器在很多方面简单地减少?如果是,在rails-sass gem中是否有一个选项?
background:red;
color:green;
}
.test2 {
background:red;
color:green;
}
span {
background:green;
color:inherit;
}
.test2 {
background:inherit!important;
color:inherit;
color:inherit;
color:inherit;
}
其他上下文:
$ b
为了澄清,我也会提出以下建议...
资料来源:
span {
background:red;
}
span {
background:orange;
color:green;
}
span {
background:yellow;
}
span {
background:blue;
color:green;
}
然后,我想要一个编译器生成以下内容:
span {
background:blue;
color:green;
}
我知道有多余的样式,但是这种情况发生很多次, ,我想消除死代码。
我认为我可能找到一种方法,至少找到重复css和sass / less模板中的样式:
开源csscss gem http://zmoazeni.github.io/csscss/
它似乎能够检测重复的,虽然我不得不猴子补丁周围的bootstrap-sass gem的css与我的css资源不在同一个文件夹。
在文档中,您可以运行:
$ csscss -v path / to / styles.css
b $ b
或
$ csscss -v path / to / styles.css.scss
I know that the css rules are fairly complex; however, couldn't the following css be fairly simply reduced in a number of ways by the optimizer? And if so, is there an option for it in the rails-sass gem?
span {
background: red;
color: green;
}
.test2 {
background: red;
color: green;
}
span {
background: green;
color: inherit;
}
.test2 {
background: inherit !important;
color: inherit;
color: inherit;
color: inherit;
}
Additional Context:
To help clarify, I would propose the following as well...
Source:
span {
background: red;
}
span {
background: orange;
color: green;
}
span {
background: yellow;
}
span {
background: blue;
color: green;
}
And, I would want a compiler to generate the following:
span {
background: blue;
color: green;
}
I know there are redundant styles, but this happens many times when continually revising stylesheets, and I want to eliminate the dead code.
I think that I may have found a way to at least find the duplicate styles in both css and sass/less templates:
The open source csscss gem http://zmoazeni.github.io/csscss/
It appears to be able to detect duplicates, although I am having to monkey patch around the bootstrap-sass gem's css not being in the same folder as my css assets.
From the documentation, you can run:
$ csscss -v path/to/styles.css
or
$ csscss -v path/to/styles.css.scss
这篇关于SASS minifier可以删除重复的样式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!