question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to alias in values from external files?

See original GitHub issue

Currently I have separated tokens into their respective package (typo, color, size etc), but how can i alias in size into typo? The generation of tokens happens in their respective packages.

like so, a spacing file at `packages/size:

{
  "size": {
    "spacing": {
      "4": { "value": "0.25rem" }
    }
  }
}

That i want to be inherited into this file, at `packages/typography:

{
  "size": {
    "line-height": {
      "4": { "value": "{tokens.size.spacing.4.value}" }
    }
  }
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dbanksdesigncommented, Mar 25, 2021

There are a few ways… For simplicity let’s focus on 2 packages, package A and package B. You want to reference a token from package A in package B.

  1. You could export an extended style dictionary from each package. The .extend() function on Style Dictionary is like creating a new instance of Style Dictionary with the configuration and tokens added into it (from source and include arrays). You can then export this object from one package (package A), import it in another package (package B) and add more tokens and configuration to it. You would need to filter out any tokens not from package A, which can be done with the new filePath attribute added in the upcoming version.
// package A
const StyleDictionary = require('style-dictionary');
module.exports = StyleDictionary.extend({
  source: [`${__dirname}/tokens/**/*.json`],
  //...
});

// package B
const spaceStyleDictionary = require('package-a');

spaceStyleDictionary.extend({
  source: [`${__dirname}/tokens/**/*.json`],
  //...
}).buildAllPlatforms();
  1. Generate a JSON file of tokens and include it This is why there is an include array in the configuration, if you wanted to include tokens from another package. In package A you can generate a plain JSON file with the json format. Then in package B you can include that generated file. You will still need to filter out tokens when generating files in package B, but there is another token attribute, isSource you can use.

Hope this helps!

0reactions
phun-kycommented, Jul 8, 2021

@chazzmoney yeah, sorry. haven’t tested the proposed solution yet, but will do. I had to manually insert values for the separate pacakges. Thank you 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

extern alias - C# Reference - Microsoft Learn
This creates the external aliases GridV1 and GridV2 . To use these aliases from within a program, reference them by using the extern...
Read more >
ALIAS statement - IBM
The syntax of the ALIAS statement is: ALIAS { directoryname [( externalsymbol )]} {(SYMLINK, pathname )} {(SYMPATH, pathname )} [,...] ... Specifies an...
Read more >
Create and remove aliases on Mac - Apple Support
Select the item, then choose File > Make Alias. You can create as many aliases for an item as you want, then drag...
Read more >
Create Aliases to Rename Members in the View - Tableau Help
In the Data pane, right-click a dimension and select Aliases. · In the Edit Aliases dialog box, under Value (Alias), select a member...
Read more >
External alias in XAML - Stack Overflow
I'm afraid the only way around this is to rip the contents of the .g.i.cs file and move it your .cs file, tweak...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found