You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The previous configuration relied on hardcoded filter arrays and manual path mappings, making it difficult to scale as new token categories were added. Additionally, the --usa-spacing-05 token was corrected in a previous PR but a build was not run. This commits the built file.
Solution
Important note for the reviewer
It appears like a lot has changed in this PR. That isn't the case. Most of the changes were to move directories around and add a top-level key to the colors files. Since directory and nesting is different, git did not flag it as a rename unfortunately. The easiest way to review this would be to look at the config file changes and verify the output files are identical to what you get when you do a fresh build on the main branch.
This PR refactors the style-dictionary configuration to dynamically generate output files (CSS and SCSS) based on the subdirectories within the tokens/ folder.
Introduced a tokens/index.js helper that reads the directory structure to define token groups.
Renamed tokens/dimension and tokens/color to pluralized versions (spacing, breakpoints, colors) to align directory names with the generated output filenames.
Streamlined the generateTokenName helper by removing manual path checks and relying on the standardized directory structure.
Major changes
Simplified style-dictionary.config.js to map over dynamic token groups instead of a static outputs array.
Renamed tokens/color/ to tokens/colors/.
Added a top-level key to all files in the tokens/colors/ directory
Renamed tokens/dimension/breakpoints.json to tokens/breakpoints/.
Renamed tokens/dimension/spacing.json to tokens/spacing/.
Refactored internals/token-helpers/index.ts to use a more generic naming convention based on file paths.
Testing and review
Run the build command (npm run build) and ensure that build/css/ and build/scss/ still contain colors, spacing, and breakpoints files with correct variable names.
Run npm test to ensure the updated generateTokenName logic passes with the new path structures.
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Simplified the style dictionary config by using the directory structure to control the logic of token output. This approach came directly from Style Dictionary's examples - https://github.com/style-dictionary/style-dictionary/tree/main/examples/advanced/matching-build-files
Related issue
Closes #272
Problem statement
The previous configuration relied on hardcoded filter arrays and manual path mappings, making it difficult to scale as new token categories were added. Additionally, the
--usa-spacing-05token was corrected in a previous PR but a build was not run. This commits the built file.Solution
Important note for the reviewer
It appears like a lot has changed in this PR. That isn't the case. Most of the changes were to move directories around and add a top-level key to the
colorsfiles. Since directory and nesting is different, git did not flag it as a rename unfortunately. The easiest way to review this would be to look at the config file changes and verify the output files are identical to what you get when you do a fresh build on themainbranch.This PR refactors the
style-dictionaryconfiguration to dynamically generate output files (CSS and SCSS) based on the subdirectories within thetokens/folder.tokens/index.jshelper that reads the directory structure to define token groups.tokens/dimensionandtokens/colorto pluralized versions (spacing,breakpoints,colors) to align directory names with the generated output filenames.generateTokenNamehelper by removing manual path checks and relying on the standardized directory structure.Major changes
style-dictionary.config.jsto map over dynamic token groups instead of a staticoutputsarray.tokens/color/totokens/colors/.tokens/colors/directorytokens/dimension/breakpoints.jsontotokens/breakpoints/.tokens/dimension/spacing.jsontotokens/spacing/.internals/token-helpers/index.tsto use a more generic naming convention based on file paths.Testing and review
npm run build) and ensure thatbuild/css/andbuild/scss/still containcolors,spacing, andbreakpointsfiles with correct variable names.npm testto ensure the updatedgenerateTokenNamelogic passes with the new path structures.