Skip to content

[WC-3392] Fix duplicate color variant imports in Atlas Core - #327

Merged
rahmanunver merged 2 commits into
mainfrom
fix/WC-3392_duplicate-variable-imports
Aug 14, 2026
Merged

[WC-3392] Fix duplicate color variant imports in Atlas Core#327
rahmanunver merged 2 commits into
mainfrom
fix/WC-3392_duplicate-variable-imports

Conversation

@rahmanunver

@rahmanunver rahmanunver commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Problem

_color-variants.scss was emitted three times into atlas_core.css, and a fourth time into the app's theme.compiled.css. Its output is a ~18 KB :root block plus shade classes, byte-identical on every emission (in atlas_core.css at output lines 481 / 859 / 1269).

Cause: a core -> theme -> core import round trip. Legacy @import is a textual paste and never dedupes.

themesource/atlas_core/web/main.scss
├─ :6  @import "color-variants"                          → emission 1
├─ :7  @import ../../../theme/web/custom-variables
│        └─ custom-variables.scss:603
│             @import ../../themesource/atlas_core/web/variables   ← the round trip
│               └─ _variables.scss:7  @import "color-variants"  → emission 2
└─ :8  @import "variables"
         └─ _variables.scss:7  @import "color-variants"         → emission 3

theme/web/main.scss                    (separate bundle → theme.compiled.css)
└─ :1  @import "custom-variables"
         └─ custom-variables.scss:603  (same round trip)
              └─ _variables.scss:7  @import "color-variants"    → emission 4

custom-variables.scss lives in theme/ — it is the app author's customization template. Reaching back down into themesource/atlas_core/ is what closed the loop, and it did so in both bundles.

Solution

One line removed, at the root:

  • Deleted the upward import at custom-variables.scss:603.
  • Removed the now-redundant direct @import "color-variants" from atlas_core/web/main.scss@import "variables" on the next line already pulls it in.
  • Added !default to $brand-colors and $lightness-steps so a future re-import cannot clobber a downstream override.

Nothing was relocated. theme/web/main.scss is untouched: theme-dark and theme-neutral use only CSS custom properties, no Sass variables, so the theme bundle never needed variables at all. Legacy Sass-variable support for modules is unaffected — it still comes from atlas_core/web/main.scss's own @import "variables".

Result

Bundle Before After Δ
atlas_core.css 835,034 800,029 −34 KB
theme.compiled.css (theme/web/) 22,737 4,721 −18 KB
atlas_web_content.css 13,098 13,098

~52 KB total. The removed declarations are byte-identical to the surviving copy in atlas_core.css (verified by comparing the extracted blocks), so nothing is lost at runtime.

validateSass passes. Note it only compiles the two themesource entries, not theme/web/main.scss — which is why the fourth emission went unnoticed.

Note on the diff

The pre-commit hook (pretty-quick) reformats custom-variables.scss wholesale on any edit — it had been committed with 2-space indentation. That churn is isolated in its own commit (style: format custom-variables.scss with prettier, whitespace plus two hex literals lowercased). The actual fix is 6 changed lines across 3 files.

@rahmanunver
rahmanunver force-pushed the fix/WC-3392_duplicate-variable-imports branch from 857b807 to 37f085f Compare August 13, 2026 09:22
Comment thread packages/atlas/src/theme/web/main.scss Outdated
Comment thread packages/atlas/src/theme/web/custom-variables.scss Outdated
Comment thread packages/atlas/src/themesource/atlas_core/web/_color-variants.scss
Comment thread packages/atlas/src/themesource/atlas_core/web/main.scss
The pre-commit hook reformats this file wholesale on any edit, since it
was committed with 2-space indentation. Isolating that churn here keeps
the accompanying change reviewable.

Whitespace, plus two hex literals lowercased by prettier (#EA3337 and
#B8BABF); CSS hex is case-insensitive so the compiled result is
unaffected.
_color-variants.scss both defined $brand-colors, $lightness-steps and
adjust-color-lightness() and emitted the :root declarations that use
them. _variables.scss needed only the definitions, so it imported the
whole file and re-emitted ~18 KB of CSS on every import. main.scss
imports variables twice (directly, and through theme/web/custom-variables),
so the block landed in atlas_core.css three times, and once more in the
app's theme.compiled.css.

Move the definitions to _color-variants-defaults.scss and import that
from both _color-variants.scss and _variables.scss. _variables.scss now
emits no CSS, so importing it repeatedly is harmless and main.scss keeps
color-variants where it belongs.

Also comment out the six brand color custom properties in
custom-variables.scss; they duplicate themes/_theme-default.scss
byte-for-byte, and every other group in that template is already
commented out for users to opt into.

atlas_core.css 835001 -> 800787 bytes, theme.compiled.css 22737 -> 5512.
@rahmanunver
rahmanunver force-pushed the fix/WC-3392_duplicate-variable-imports branch from 897358c to b841074 Compare August 14, 2026 12:19
@rahmanunver
rahmanunver merged commit 0ba3ba3 into main Aug 14, 2026
11 checks passed
@rahmanunver
rahmanunver deleted the fix/WC-3392_duplicate-variable-imports branch August 14, 2026 13:12
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.

3 participants