Skip to content

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

Open
rahmanunver wants to merge 3 commits into
mainfrom
fix/WC-3392_duplicate-variable-imports
Open

[WC-3392] Fix duplicate color variant imports in Atlas Core#327
rahmanunver wants to merge 3 commits into
mainfrom
fix/WC-3392_duplicate-variable-imports

Conversation

@rahmanunver

Copy link
Copy Markdown
Contributor

Problem

_color-variants.scss was emitted three times into atlas_core.css. Its output is a single 16,987-byte :root block, so the file carried ~34 KB of byte-identical duplication (compiled output lines 481 / 859 / 1269).

Cause: a core -> theme -> core import round trip, and legacy @import 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
│               └─ _variables.scss:7  @import "color-variants"  → emission 2
└─ :8  @import "variables"
         └─ _variables.scss:7  @import "color-variants"         → emission 3

custom-variables.scss lives in theme/ — it is the app author's customization template. It importing back down into themesource/atlas_core/ is what closes the loop.

Solution

  • Removed the upward import at custom-variables.scss:603.
  • Relocated it to theme/web/main.scss, where theme authors legitimately need the Sass variables. Placed after custom-variables so $use-css-variables is set before variables reads it.
  • Removed the now-redundant direct @import "color-variants" from atlas_core/web/main.scss; @import "variables" already pulls it in.
  • Added !default to $brand-colors and $lightness-steps so a future re-import cannot clobber a downstream override.

Net: 9 insertions, 4 deletions.

Result

Bundle Before After
atlas_core.css 835,034 800,029
theme_web.css 22,737 22,737
atlas_web_content.css 13,098 13,098

atlas_core.css −35,005 B (−4.2%). The other two bundles compile byte-identical. validateSass passes.

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). Review the second commit for the actual fix.

The pre-commit hook reformats this file wholesale on any edit, since it
was previously committed with 2-space indentation. Isolating that churn
here keeps the follow-up fix reviewable.

Whitespace only, plus two hex literals lowercased by prettier
(#EA3337, #B8BABF). Compiled CSS is unaffected.
theme/web/custom-variables.scss imported back into
themesource/atlas_core/web/variables, forming a core -> theme -> core
round trip. Combined with main.scss importing color-variants directly,
the output of color-variants was emitted three times in atlas_core.css.

Move the variables import from custom-variables.scss up to
theme/web/main.scss, drop the now redundant color-variants import from
atlas_core/web/main.scss, and add !default to $brand-colors and
$lightness-steps so a future re-import cannot clobber downstream
overrides.

Reduces atlas_core.css by 35005 bytes (4.2%). The theme and web_content
bundles compile byte-identical.
@rahmanunver
rahmanunver force-pushed the fix/WC-3392_duplicate-variable-imports branch from 857b807 to 37f085f Compare August 13, 2026 09:22
@import "custom-variables";
// Sass variables for theme authors. Must come after custom-variables so that
// $use-css-variables is already set when variables reads it.
@import "../../themesource/atlas_core/web/variables";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why is this here?
and why is it using ../../. to access the variables that it's own modules have?

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