Skip to content

v4.0.0-prerelease.20

Pre-release
Pre-release
Compare
Choose a tag to compare
@github-actions github-actions released this 25 Mar 16:45
· 135 commits to main since this release
5f2f8c5

Minor Changes

  • aff6646: Allow passing a custom FileSystem Volume to your Style-Dictionary instances, to ensure input/output files are read/written from/to that specific volume.
    Useful in case you want multiple Style-Dictionary instances that are isolated from one another in terms of inputs/outputs.

    import { Volume } from 'memfs';
    // You will need a bundler for memfs in browser...
    // Or use as a prebundled fork:
    import memfs from '@bundled-es-modules/memfs';
    const { Volume } = memfs;
    
    const vol = new Volume();
    
    const sd = new StyleDictionary(
      {
        tokens: {
          colors: {
            red: {
              value: '#FF0000',
              type: 'color',
            },
          },
        },
        platforms: {
          css: {
            transformGroup: 'css',
            files: [
              {
                destination: 'variables.css',
                format: 'css/variables',
              },
            ],
          },
        },
      },
      { volume: vol },
    );
    
    await sd.buildAllPlatforms();
    
    vol.readFileSync('/variables.css');
    /**
     * :root {
     *   --colors-red: #FF0000;
     * }
     */

    This also works when using extend:

    const extendedSd = await sd.extend(cfg, { volume: vol });