Style-dictionary: SD 3.0 output references

Created on 25 Mar 2021  路  3Comments  路  Source: amzn/style-dictionary

After following https://amzn.github.io/style-dictionary/#/version_3?id=output-references, I noticed this works most of the time, but for some reason it generates the following scss errors for nested aliased properties. Does the output account for alias dependencies?

This throws a SassError: Undefined variable..

I couldn't find a relating issue, is this a known issue?

Input

Config

files: [
  {
    destination: '_variables.scss',
    format: 'scss/variables',
    options: {
      outputReferences: true,
    },
  },
],

Font

{
  "font": {
    "family": {
      "custom": {
        "value": "'Helvetica Neue', Helvetica, Arial, sans-serif"
      },

      "default": { "value": "{font.family.custom.value}", "themeable": true }
    }
  }
}

Component

{
  "component": {
    "alert": {
      "fontFamily": {
        "value": "{font.family.default.value}",
        "themeable": true
      }
    }
  }
}

Output

_variables.scss

$font-family-custom: 'Helvetica Neue', Helvetica, Arial, sans-serif;
$component-alert-font-family: $font-family-default !default;
$font-family-default: $font-family-custom !default;

$font-family-default is placed at the end of the file, but is used prior to being defined.

Most helpful comment

Ah, it looks like in the scss/variables format we are sorting all the tokens to make sure references are at the end, but not accounting for nested references... We need to fix that somehow

All 3 comments

Ah, it looks like in the scss/variables format we are sorting all the tokens to make sure references are at the end, but not accounting for nested references... We need to fix that somehow

This is fixed and will make it out in the next release candidate we will publish this week.

Closing this as this should be fixed in the latest release candidate of 3.0.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dbanksdesign picture dbanksdesign  路  5Comments

chazzmoney picture chazzmoney  路  4Comments

chazzmoney picture chazzmoney  路  4Comments

gael-boyenval picture gael-boyenval  路  3Comments

matt-tyas picture matt-tyas  路  3Comments