Skip to content

fix(plugin-sass): forward CSS plugin's localID in transform hook - #765

Merged
drwpow merged 3 commits into
terrazzoapp:mainfrom
mrisoli:fix/plugin-sass-forward-css-localid
Jun 7, 2026
Merged

drwpow merged 3 commits into
terrazzoapp:mainfrom
mrisoli:fix/plugin-sass-forward-css-localid

Conversation

@mrisoli

@mrisoli mrisoli commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes a regression in @terrazzo/plugin-sass where the CSS plugin's variableName customization (prefixes, casing) was not honored by the generated $__token-values Sass map.

plugin-sass's transform hook was setting localID: token.id (the dotted DTCG id), which build.ts then read via getTransforms({ format: FORMAT_ID }) and turned into a CSS variable name from scratch — bypassing the CSS plugin's variableName and producing var(--color-blue-40) instead of var(--ds-color-blue-40). The typography mixins map was unaffected because that loop queries format: 'css' directly.

Forwarding token.localID instead preserves any prefix or casing customization configured via variableName on plugin-css.

Root cause

Regression introduced in 2.2.0 (PR #589) when the main loop in build.ts switched from format: 'css' to format: FORMAT_ID.

Changes

  • packages/plugin-sass/src/index.ts: forward token.localID instead of token.id in the setTransform call.
  • Added changeset (@terrazzo/plugin-sass: patch).

The sass transform was setting `localID: token.id` (the dotted DTCG
id), which the main `$__token-values` loop in build.ts then turned
into a CSS variable name from scratch — bypassing the CSS plugin's
`variableName` and producing `var(--color-blue-40)` instead of
`var(--pcl-color-blue-40)`. The typography mixins map was unaffected
because that loop queries `format: 'css'` directly.

Forwarding `token.localID` instead preserves any prefix or casing
customization configured via `variableName` on plugin-css.

Regression introduced in 2.2.0 (PR terrazzoapp#589) when the main loop in
build.ts switched from `format: 'css'` to `format: FORMAT_ID`.
@changeset-bot

changeset-bot Bot commented Jun 2, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 79bd093

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@terrazzo/plugin-sass Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

mrisoli added 2 commits June 2, 2026 11:06
The basic fixture configures plugin-css with a 'ds' variableName prefix.
With localID now forwarded, the $__token-values Sass map correctly
references the --ds- prefixed CSS variables, matching want.css.

@drwpow drwpow left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great fix! Agree with just updating the existing test here—this should cover the behavior. Ashamed I didn’t notice the prefix was missing in the fixture!

@drwpow
drwpow merged commit 27c13ff into terrazzoapp:main Jun 7, 2026
4 checks passed
@github-actions github-actions Bot mentioned this pull request Jun 7, 2026
@mrisoli
mrisoli deleted the fix/plugin-sass-forward-css-localid branch June 9, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants