question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Conditional imports don't work in scss

See original GitHub issue

Describe the bug

When using a conditional import in scss, the output isn’t processed correctly. image SCSS variables are still in the output: image

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

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
tony19commented, Aug 17, 2022

@obj-obj I think you meant to use @media (prefers-color-scheme: dark) rule, right? That seems to work.

Kapture 2022-08-16 at 22 33 48

1reaction
obj-objcommented, Aug 16, 2022

If you are saying about this, I think it should work.

@media (max-width: 768px) {
  @import './foo';
}

That doesn’t work. Time to make another issue then

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found