css / csso

CSS minifier with structural optimizations
https://css.github.io/csso/csso.html
MIT License
3.75k stars 188 forks source link

Is there a way to remove duplication of properties in the `@media`? #440

Open cawa-93 opened 3 years ago

cawa-93 commented 3 years ago

I would like to configure compiling of css with different theme configurations so as to avoid duplicating common properties.

Test case:

.foo {
    color: red;
    padding: 10px;
}

@media(prefers-color-scheme: dark) {
    .foo {
        color: tomato;
        padding: 10px;
    }
}

Actual output:

.foo {
    color: red;
    padding: 10px
}

@media (prefers-color-scheme:dark) {
    .foo {
        color: tomato;
        padding: 10px
    }
}

Expected output:

.foo {
    color: red;
    padding: 10px
}

@media (prefers-color-scheme:dark) {
    .foo {
        color: tomato;
        /* no more padding */
    }
}