For obvious reasons you can't have some effect without doing anything for it :)
However, in your case, you could want to use placeholder selector alongside with root reference:
.header,
$foo {
font-weight: bold;
&--main,
/$foo {
font-family: 'Segoe UI', sans-serif;
}
&--type-error,
/$foo {
color: red;
}
&--main&--type-error,
/$foo {
font-size: 1.2em;
}
}
.Error__header {
@extend $foo;
}
would be equal to the code you wrote. And if you'd wanted not to have all the selectors like .Error__header--main.Error__header--type-error
generated and only the .Error__header
added to each of those, you can do this:
.header {
&,
/$foo {
font-weight: bold;
}
&--main,
/$foo {
font-family: 'Segoe UI', sans-serif;
}
&--type-error,
/$foo {
color: red;
}
&--main&--type-error,
/$foo {
font-size: 1.2em;
}
}
.Error__header {
@extend $foo;
}
and this would compile to
.header,
.Error__header {
font-weight: bold;
}
.header--main,
.Error__header {
font-family: 'Segoe UI', sans-serif;
}
.header--type-error,
.Error__header {
color: #f00;
}
.header--main.header--type-error,
.Error__header {
font-size: 1.2em;
}