Unless I am misstaken (please tell me if I am!) it is not possible to use Liquid in SCSS.
From what I gather there are good reasons for this, so I am fine with that.
However it would very helpful if we could include different SCSS files based on some setting, for example in the config, or -hopefully- even in a data file.
Actually I think it is possible to use liquid inside SCSS files, the first example that comes to mind is the use of bringing in a SCSS file as an include from a theme https://github.com/pages-themes/cayman#stylesheet
I can’t find where I did it now, but at one point I wanted to put something from the config file into an scss file, and I think what happened is it did not work by directly putting it in one of the partials but it did work by making it a variable - I think in the variables partial I had, or maybe it was in the main.scss file that imported all the partials. At any rate I did get it to do what I wanted, it just had to be made into a scss variable - and where that happened seemed to matter.
I don’t think that is liquid, maybe it is syntactically equivalent, but liquid was removed from SCSS files somewhere in the v2.1 or v2.2 (iirc) of Jekyll.
Anyway, I would need to control the loading of scss files depending on config (or data files). And not just including it, but including it conditionally on other variables. Ideally even conditionally on YAML frontmatter!
Oh, really? I’m sure I’ve done something like this quite recently but I might be wrong. @rdyar sounds like they may have something there. Can I just ask, does it need to be a conditional statement? Can’t it just be set with a class? Or are you trying to keep tight with perf aspects and keep the CSS file small?
What about loading certain .scss files based on liquid conditionals? Say for example, I have a special div on certain pages and I don’t want the .scss related to that div to load on other pages. Can I just;
{% if data.specialDiv or page.specialDiv or site.collections.specialDiv %}
@import
"theme/div/specialDivDefaultSCSS",
"theme/div/specialDivCustomSCSS";
{% endif %}