yea2021
yea2021

Reputation: 77

SCSS @if variable == value @import not possible?

I am using scss in a project. I have a variable which depending on it's value I want to determine which scss file is imported.

So I'm trying this:

$test: 1;

@if $test == 1 {
  @import "./theme1.scss";
}

Error I'm getting is:

'This at-rule is not allowed here.'

Can this be done? If so how?

Upvotes: 0

Views: 1744

Answers (1)

Adam Perea
Adam Perea

Reputation: 399

Import directives may not be used within control directives or mixins. It is a feature discussed in sass GitHub, but never implemented and won't be by soon.

You should just import your scss file directly without any condition.

You can find more information under the same question here.

Upvotes: 1

Related Questions