postcss / postcss-nested

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

Changing the default "collapsing" behavior #78

Closed matthew-dean closed 5 years ago

matthew-dean commented 5 years ago

Could a feature be added to change the default behavior of nested selectors to not append a space? That is, have this:

.a {
  .b { ... }
  :hover { ... }
}

compile to:

.a.b { ... }
.a:hover { ... }

And then requiring & to include a space like:

.a {
  & .b { ... }
  & :hover { ... }
}

Styled-components does something like this for pseudo-elements / pseudo-selectors. (Maybe an option to just select those? Or omit spaces from all?) See: https://www.styled-components.com/docs/basics#pseudoelements-pseudoselectors-and-nesting

ai commented 5 years ago

It is much easy to make fork of the plug-in with different behavior.

I will post a link to your solution.