leafo / scssphp

SCSS compiler written in PHP
MIT License
1.34k stars 216 forks source link

Fails to generate correct .css in nested @each loop. #705

Closed alexsaalberg049 closed 5 years ago

alexsaalberg049 commented 5 years ago

scssphp version 0.8.2

Description: It's a pretty simple issue to describe: scssphp does not process the .scss file correctly.

It should generate the file shown in 3, but simply does not generate any of the .bg-{COLOR}-{NUMBER} rules it should be in that inner @each loop.

It's possible that there's something quirky about my environment, so someone else should probably confirm the issue exists with their scssphp aswell.

Relevant Stuff:

  1. Source .scss File
  2. Resulting .css File
  3. Online SCSS tool showing proper .css file

Other

robocoder commented 5 years ago

Reproduceable in v0.8.3 and master (2e5e474b).

robocoder commented 5 years ago

(Comment deleted)

Looks like it's the nested map that's the source of grief.

robocoder commented 5 years ago

It doesn't like maps where the key is a list. Flipping the key/value is the workaround, e.g.,

$oc-gray-list: (
        "0": #f8f9fa,
        "1": #f1f3f5
);

$oc-red-list: (
        "0": #fff5f5,
        "1": #ffe3e3
);

$oc-color-list: (
    "gray": $oc-gray-list,
    "red": $oc-red-list
);

@each $color-name, $color-list in $oc-color-list {
  @each $color-index, $color in $color-list {
    .bg-#{$color-name}-#{$color-index} {
      background-color: $color;
    }
  }
}
Cerdic commented 5 years ago

This is now fix: see https://github.com/scssphp/scssphp/issues/3