postcss / postcss-nested

PostCSS plugin to unwrap nested rules like how Sass does it.
MIT License
1.16k stars 66 forks source link

Conflict with postcss-nested and postcss-extend #35

Closed Dylan-Chapman closed 8 years ago

Dylan-Chapman commented 8 years ago

I'm trying to extend from within a nested selector. I can't quite figure out how to get everything working.

Input:

@import "silent-placeholders.css";

%inline-placeholder {
    content: "test";
}

.test {
    color: red;

    &:before {
        @extend %inline-placeholder;
    }
}

If postcss-extend is included first and postcss-nested is included after, the output is:

&:before {
    content: "test";
}

.test {
    color: red;
}

If postcss-nested is included first and postcss-extend is included after, %silent-placeholders from silent-placeholders.css (for use with postcss-extend) are copied into the CSS output. Is there a way to not have these silent placeholders in the output?

ai commented 8 years ago

Sorry, I never uses extend, because it very dangerous. So I reallycan’t understand right output. But I am open for PR.

Also, why you don’t want to try postcss-mixins? it generates much safer output.

Here is a text, why yu should avoid extend: http://www.sitepoint.com/avoid-sass-extend/

Dylan-Chapman commented 8 years ago

So, I managed to get my code working by using mixins and by refactoring a bit. I didn't realize after gzip that file size difference was negligible (my primary reason for using extend was for file size). Thanks!