Exporting SCSS Variables to JS (auto looping variables)

前端 未结 3 1359
闹比i
闹比i 2021-02-02 10:28

UPDATE: If you plan to implement the export solution, you must place it in a separate file to prevent redundant e

3条回答
  •  被撕碎了的回忆
    2021-02-02 11:04

    Taking a Cue from Bootstrap 4, you could combine a SASS map with a loop like below;

    /* Define all colours */
    $theme-colours: (
      some-color: #000,
      another-color: #000,
      third-color: #000,
      fourth-color: #000
    )
    
    @each $color, $value in $theme-colours {
      :export{
        $color: $value;
      }
    }

    Here's some examples from the Bootstrap 4 Docs

提交回复
热议问题