Reputation: 1230
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.
Upvotes: 23
Views: 14937
Reputation: 1230
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
Upvotes: 6
Reputation: 3002
Not that I know of, SASS will only format your code differently but not optimize it for you http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#output_style
Expanding on Whymarrh's comment, CSSTidy has a command line utility that could be integrated in a build process or similar, http://packages.ubuntu.com/hardy/csstidy
Upvotes: 1