postcss-extend-rule icon indicating copy to clipboard operation
postcss-extend-rule copied to clipboard

Not working with nested media queries

Open spacedawwwg opened this issue 6 years ago • 6 comments

Using postcss-extend-rule and postcss-nesting together but coming across an issue where @extend definitions nested media queries are being stripped.

.foo {
    color: red
}

.bar {
    color: blue;

    @media (min-width: 768px) {
        @extend .red;
    }
}

I would expect

.foo {
    color: red
}

.bar {
    color: blue;
}

@media (min-width: 768px) {
    .bar {
        color: red;
    }
}

spacedawwwg avatar May 30 '19 09:05 spacedawwwg

I am also experiencing this issue:

%font--gillsans-medium {
    font-family: 'GillSansMTStd-Medium', sans-serif;
}

.navigation {
    &__link {
        @postcss-extend %font--mrseaves-roman;
        
        @media (--from-tablet) {
            @postcss-extend %font--gillsans-medium;
            // Other CSS rules here
        }
    }
}

The override font extension is being stripped out from inside the media query, however all the other CSS rules, including mixins, are working correctly

edward-simpson avatar Jun 24 '19 13:06 edward-simpson

Yes, I noticed this bug, and I don’t like it either. I think the plugin should be re-written to accept the context of the rule being extended.

jonathantneal avatar Jul 29 '19 13:07 jonathantneal

I'm having the same problem, did anyone find a way to overcome this?

aacoelho avatar Oct 29 '20 12:10 aacoelho

Only way I found was to stop using postcss-extend (moved my font declarations into mixins)

edward-simpson avatar Nov 02 '20 10:11 edward-simpson

Thank you, I would also like to voluntarily participate in the organization and provide assistance :) have a good work.

nisancigokmen avatar Apr 06 '22 21:04 nisancigokmen

Works on my machine™ I have postcss-extend-rule come before postcss-nested & postcss-custom-media

42tte avatar Nov 28 '23 14:11 42tte