How to use the style-dictionary.registerAction function in style-dictionary

To help you get started, we’ve selected a few style-dictionary examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github davixyz / design-tokens / src / actions.js View on Github external
'utf8'
    );
    const compiledTemplate = _.template(iconsTemplate);
    const compiledIconsTemplate = compiledTemplate({ data: assetNameArr });
    fs.outputFileSync(
      path.join(__dirname, '../build/ios/Classes/Image.swift'),
      compiledIconsTemplate
    );
  },
  undo(dictionary, config) {
    log(`Removing icons directory from ${config.buildPath} assets`);
    fs.removeSync(config.buildPath);
  },
});

StyleDictionary.registerAction({
  name: 'copy_icons_android',
  do(dictionary, config) {
    log('Copying icons directory');
    const assetsPath = path.join(__dirname, 'assets/icons/');
    const assetPathArr = fs
      .readdirSync(assetsPath)
      .filter(asset => asset !== '.DS_Store')
      .map(file => {
        const assetPath = path.join(assetsPath, file);
        const parsedPath = path.parse(assetPath);
        return {
          name: parsedPath.name,
          path: assetPath,
        };
      });
    // Processor of SVG before shipping

style-dictionary

Style once, use everywhere. A build system for creating cross-platform styles.

Apache-2.0
Latest version published 3 months ago

Package Health Score

98 / 100
Full package analysis