Conditional imports don't work in scss
See original GitHub issueDescribe the bug
When using a conditional import in scss, the output isn’t processed correctly.
SCSS variables are still in the output:

Related to https://github.com/withastro/astro/issues/2883
Reproduction
https://stackblitz.com/edit/vitejs-vite-qvvgg9
System Info
System:
OS: Linux 5.19 undefined
CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
Memory: 6.23 GB / 15.42 GB
Container: Yes
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.7.0 - /usr/bin/node
npm: 8.17.0 - /usr/bin/npm
Browsers:
Firefox: 103.0.2
Used Package Manager
pnpm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
css - @import in @if statement in Sass - Stack Overflow
It is currently not possible to use SASS to include files dynamically. @import cannot be used within control directives (e.g. @if ) or...
Read more >Allow @import within @if · Issue #451 · sass/sass - GitHub
There was a bug where an @import that was nested conditionally in a file that was itself imported didn't get checked properly for...
Read more >Conditional sass imports? - Google Groups
I'm trying to do something like below but it seems imports don't work inside conditionals. Inside base.scss I have this... $stylesheet: 'base';
Read more >Sass: @import
When Sass imports a file, that file is evaluated as though its contents appeared directly in place of the @import . Any mixins,...
Read more >Dynamic, Conditional Imports - CSS-Tricks
It is a simple JavaScript package that injects a (virtual, ) confetti explosion into whatever web page you are working on. Finished a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@obj-obj I think you meant to use
@media (prefers-color-scheme: dark)rule, right? That seems to work.That doesn’t work. Time to make another issue then