Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

«Invalid CSS after» after use map.get #2890

Closed
Psixodelik opened this issue Apr 14, 2020 · 8 comments
Closed

«Invalid CSS after» after use map.get #2890

Psixodelik opened this issue Apr 14, 2020 · 8 comments

Comments

@Psixodelik
Copy link

Hi.

I ran into a problem that node-sass does not want to process the following mixin:

@mixin colors($colors) {
  $tone: "light";

  @if $dark-theme {
    $tone: "dark";
  }

  @each $color-name, $color-value in $colors {
    .bg-#{$color-name} {
      background: #{map.get($color-value, $tone)};
    }
    .text-#{$color-name} {
      color: #{map.get($color-value, $tone)};
    }
  }
}

After starting, I get the following message:

Invalid CSS after "...ckground: #{map": expected expression (e.g. 1px, bold), was ".get($color-value, ".

How to fix this problem? The regular SASS compiler accepts this code without problems.

@saper
Copy link
Member

saper commented Apr 16, 2020

can you give me example how are you using this mixin?

@saper
Copy link
Member

saper commented Apr 16, 2020

(This might be sass/libsass#2309)

@mgreter
Copy link
Contributor

mgreter commented Apr 19, 2020

The error is quite explicit IMO

Error: Invalid CSS after "...ckground: #{map": expected expression (e.g. 1px, bold), was ".get($color-value, "
        on line 10:24 of /stdin
>>       background: #{map.get($color-value, $tone)};
   -----------------------^

It's map-get, not map.get.

@mgreter mgreter closed this as completed Apr 19, 2020
@pinoniq
Copy link

pinoniq commented Oct 28, 2020

the sass-lang docs show map.get: https://sass-lang.com/documentation/values/maps

@Zardoz89
Copy link

Zardoz89 commented Nov 4, 2020

I lost like a hour before I understand that the documentation it wrong... PLEASE FIX ASAP

@mikeaustin
Copy link

The documentation still seems to be wrong. https://sass-lang.com/documentation/modules/map
I'd be happy to update the docs, but I feel someone who has more experience with sass would be more appropriate.

@xzyfer
Copy link
Contributor

xzyfer commented Jun 28, 2021

Node sass does not support sass modules. For that capability you'll need to switch to dart-sass.

@emmaYugen
Copy link

Thank you for the information, up until then, I used node-sass for sass modules, and it worked, thought.
Since when doesn't it support it anymore ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants