I am looking for a way to conditionally include content based on a context. The two output files will pull in the same sass files but just process them differently. I would imagine it to work similarly to the @content mixin just without pulling in all the other styles outside of the mixin at the same time. I just need the body of what is included in the mixin. Does anyone have any ideas how I can achieve this?
It is very similar to what https://github.com/at-import/jacket does but without the compass dependency. I have included an example so you can see what kind of thing I am after:
// _styles.scss
h1 {
color: red;
}
h2 {
color: green;
}
@include critical {
.someModule {
background-color: red;
height: 50px;
}
}
These would then be imported into two separate stylesheets like so
// output.scss
@import "styles";
// critical.scss
@import "styles";
But when the SASS compiles you would end up with:
// output.css
h1 {
color: red;
}
h2 {
color: green;
}
// critical.css
.someModule {
background-color: red;
height: 50px;
}
Instead of output.css and critical.css both including the content:
// output.css and critical.css
h1 {
color: red;
}
h2 {
color: green;
}
.someModule {
background-color: red;
height: 50px;
}