storybook-design-token icon indicating copy to clipboard operation
storybook-design-token copied to clipboard

Request: allow customization of token locations

Open emzarts opened this issue 2 years ago • 4 comments

It would be super awesome to have the ability to specify a file location for the tokens! We currently have a use case where we want to store the tokens in their own package separate from our storybook implementation. So the ability to:

  1. Use files outside the compiler.context
  2. specify which file paths to ignore/ not ignore

would be awesome!

This is the relevant section of the addon code:

  return glob.sync(
    path.join(
      compiler.context,
      process.env.DESIGN_TOKEN_GLOB || '**/*.{css,scss,less,svg,png,jpeg,gif}'
    ),
    {
      ignore: ['**/node_modules/**', '**/storybook-static/**', '**/*.chunk.*']
    }
  );

Thanks!!

emzarts avatar Jul 28 '22 17:07 emzarts

This can be achieved already? with env variables: DESIGN_TOKEN_GLOB=../../somewhere/**/tokens.{css,scss,less,svg}

jbvolvo avatar Jul 29 '22 12:07 jbvolvo

@jbvolvo Could you please provide an example how to configure this? I was following this doc - https://storybook.js.org/docs/react/configure/environment-variables#using-storybook-configuration, but didn't succeed...

mis6ko13 avatar Aug 05 '22 16:08 mis6ko13

@jbvolvo Could you please provide an example how to configure this? I was following this doc - https://storybook.js.org/docs/react/configure/environment-variables#using-storybook-configuration, but didn't succeed...

This method only worked for me with the using .env file. That populates the environment variables during the build phase.

emzarts avatar Aug 05 '22 17:08 emzarts

This can be achieved already? with env variables: DESIGN_TOKEN_GLOB=../../somewhere/**/tokens.{css,scss,less,svg}

Sorry I didn't clarify more! I would like to have the option to import from other sources than just a GLOB. Like a node module (which is filered out of the GLOB using the ignore param)

emzarts avatar Aug 05 '22 17:08 emzarts