Skip to content

fix(vibe-tests): disable lightningcss in report build — fixes missing styles - #558

Merged
cixzhang merged 1 commit into
mainfrom
navi/fix/report-dist-imports
Mar 10, 2026
Merged

fix(vibe-tests): disable lightningcss in report build — fixes missing styles#558
cixzhang merged 1 commit into
mainfrom
navi/fix/report-dist-imports

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

Problem

Vibe test reports have no visible styles. All theme colors are invisible.

Root Cause

LightningCSS (used as cssMinify) was lowering native light-dark() into polyfill variables (--lightningcss-light/--lightningcss-dark). These polyfill variables are never initialized in the report HTML, so all token values resolve to empty — making everything invisible.

The lightningcssTargets config was supposed to prevent this, but lightningcss still lowered light-dark() during CSS transformation.

Fix

Disable CSS minification in the report build (cssMinify: false). The pre-compiled CSS from @xds/core/dist/xds.css is already production-ready.

Also cleans up the resolve aliases to use regex-based matching for @xds/core subpath imports.

Verification

Before: --color-wash:var(--lightningcss-light,#f1f4f7)var(--lightningcss-dark,#111112)
After: --color-wash:light-dark(#F1F4F7, #111112)

LightningCSS was lowering native light-dark() into polyfill variables
(--lightningcss-light/--lightningcss-dark) despite browser targets being
set. These polyfill variables are never initialized in the report,
causing all theme colors to be invisible.

The pre-compiled CSS from @xds/core/dist/xds.css is already minified,
so CSS minification in the report build is unnecessary.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core 9.1KB 14.7KB 2.3KB

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@cixzhang
cixzhang merged commit 76ecc62 into main Mar 10, 2026
14 checks passed
@cixzhang
cixzhang deleted the navi/fix/report-dist-imports branch March 10, 2026 01:44
cixzhang pushed a commit that referenced this pull request Mar 11, 2026
Same fix as the report build (PR #558) — lightningcss mangles
light-dark() into polyfill variables that never get set, causing
XDS styles to be invisible in previews.

The StyleX plugin already handles CSS extraction with proper targets.
Setting cssMinify: false prevents Vite's build phase from running
lightningcss again and breaking the output.
cixzhang added a commit that referenced this pull request Mar 15, 2026
… breakage

LightningCSS lowers CSS light-dark() into polyfill variables
(--lightningcss-light/--lightningcss-dark) that are never initialized,
silently breaking all XDS theming colors. This has bitten us 3 separate
times (PRs #558, #566, #499) across different Vite configs.

Changes:
- apps/example-vite/vite.config.ts: add build.cssMinify: false
- apps/storybook/vite.config.ts: add build.cssMinify: false
- apps/example-vite/README.md: add lightningcss gotcha as top entry,
  detailed explanation section, and update inline config example
- apps/example-nextjs/README.md: add awareness note (Next.js uses
  PostCSS so not directly affected, but warn about custom minifiers)

Co-authored-by: Navi <navi@navibot.dev>
cixzhang added a commit that referenced this pull request Mar 15, 2026
… breakage (#623)

LightningCSS lowers CSS light-dark() into polyfill variables
(--lightningcss-light/--lightningcss-dark) that are never initialized,
silently breaking all XDS theming colors. This has bitten us 3 separate
times (PRs #558, #566, #499) across different Vite configs.

Changes:
- apps/example-vite/vite.config.ts: add build.cssMinify: false
- apps/storybook/vite.config.ts: add build.cssMinify: false
- apps/example-vite/README.md: add lightningcss gotcha as top entry,
  detailed explanation section, and update inline config example
- apps/example-nextjs/README.md: add awareness note (Next.js uses
  PostCSS so not directly affected, but warn about custom minifiers)

Co-authored-by: Navi <navi@navibot.dev>
cixzhang added a commit that referenced this pull request Mar 15, 2026
LightningCSS lowers light-dark() into --lightningcss-light/--lightningcss-dark
polyfill variables for older browsers. This polyfill actually works correctly
IF the color-scheme declaration is in the same CSS file — lightningcss injects
toggle variable initialization wherever it sees color-scheme. But when
light-dark() and color-scheme are in separate files (as with XDS, where
tokens are in xds.css but color-scheme is set by XDSTheme via StyleX),
the polyfill vars are used but never defined, breaking all colors.

Fix: include `color-scheme: light dark` in both xds.css and theme CSS
output so the polyfill is self-contained. This makes XDS CSS compatible
with any bundler that runs lightningcss regardless of target configuration.

This reverts the cssMinify: false workarounds from PR #623 and earlier
(PRs #558, #566) since they're no longer needed — the root cause is fixed.

Co-authored-by: Navi <navi@navibot.dev>
cixzhang added a commit that referenced this pull request Mar 15, 2026
LightningCSS lowers light-dark() into --lightningcss-light/--lightningcss-dark
polyfill variables for older browsers. This polyfill actually works correctly
IF the color-scheme declaration is in the same CSS file — lightningcss injects
toggle variable initialization wherever it sees color-scheme. But when
light-dark() and color-scheme are in separate files (as with XDS, where
tokens are in xds.css but color-scheme is set by XDSTheme via StyleX),
the polyfill vars are used but never defined, breaking all colors.

Fix: add `color-scheme: light dark` to:
- reset.css — on :where(html), the canonical place for the declaration.
  Every XDS app imports this first.
- build-css.mjs output (xds.css) — for consumers who import xds.css
  without reset.css
- build-theme.mjs output (theme.css) — for theme files containing
  light-dark() values

This makes XDS CSS compatible with any bundler that runs lightningcss
regardless of target configuration. Reverts the cssMinify: false
workarounds from PR #623 and earlier (PRs #558, #566).

Co-authored-by: Navi <navi@navibot.dev>
cixzhang added a commit that referenced this pull request Mar 15, 2026
LightningCSS lowers light-dark() into --lightningcss-light/--lightningcss-dark
polyfill variables for older browsers. This polyfill actually works correctly
IF the color-scheme declaration is in the same CSS file — lightningcss injects
toggle variable initialization wherever it sees color-scheme. But when
light-dark() and color-scheme are in separate files (as with XDS, where
tokens are in xds.css but color-scheme is set by XDSTheme via StyleX),
the polyfill vars are used but never defined, breaking all colors.

Fix: add `color-scheme: light dark` to:
- reset.css — on :where(html), the canonical place for the declaration.
  Every XDS app imports this first.
- build-css.mjs output (xds.css) — for consumers who import xds.css
  without reset.css
- build-theme.mjs output (theme.css) — for theme files containing
  light-dark() values

This makes XDS CSS compatible with any bundler that runs lightningcss
regardless of target configuration. Reverts the cssMinify: false
workarounds from PR #623 and earlier (PRs #558, #566).

Co-authored-by: Navi <navi@navibot.dev>
cixzhang added a commit that referenced this pull request Mar 15, 2026
LightningCSS lowers light-dark() into --lightningcss-light/--lightningcss-dark
polyfill variables for older browsers. This polyfill actually works correctly
IF the color-scheme declaration is in the same CSS file — lightningcss injects
toggle variable initialization wherever it sees color-scheme. But when
light-dark() and color-scheme are in separate files (as with XDS, where
tokens are in xds.css but color-scheme is set by XDSTheme via StyleX),
the polyfill vars are used but never defined, breaking all colors.

Fix: add `color-scheme: light dark` to:
- reset.css — on :where(html), the canonical place for the declaration.
  Every XDS app imports this first.
- build-css.mjs output (xds.css) — for consumers who import xds.css
  without reset.css
- build-theme.mjs output (theme.css) — for theme files containing
  light-dark() values

This makes XDS CSS compatible with any bundler that runs lightningcss
regardless of target configuration. Reverts the cssMinify: false
workarounds from PR #623 and earlier (PRs #558, #566).

Co-authored-by: Navi <navi@navibot.dev>
cixzhang added a commit that referenced this pull request Mar 15, 2026
LightningCSS lowers light-dark() into --lightningcss-light/--lightningcss-dark
polyfill variables for older browsers. This polyfill actually works correctly
IF the color-scheme declaration is in the same CSS file — lightningcss injects
toggle variable initialization wherever it sees color-scheme. But when
light-dark() and color-scheme are in separate files (as with XDS, where
tokens are in xds.css but color-scheme is set by XDSTheme via StyleX),
the polyfill vars are used but never defined, breaking all colors.

Fix: add `color-scheme: light dark` to:
- reset.css — on :where(html), the canonical place for the declaration.
  Every XDS app imports this first.
- build-css.mjs output (xds.css) — for consumers who import xds.css
  without reset.css
- build-theme.mjs output (theme.css) — for theme files containing
  light-dark() values

This makes XDS CSS compatible with any bundler that runs lightningcss
regardless of target configuration. Reverts the cssMinify: false
workarounds from PR #623 and earlier (PRs #558, #566).

Co-authored-by: Navi <navi@navibot.dev>
cixzhang added a commit that referenced this pull request Apr 26, 2026
)

LightningCSS was lowering native light-dark() into polyfill variables
(--lightningcss-light/--lightningcss-dark) despite browser targets being
set. These polyfill variables are never initialized in the report,
causing all theme colors to be invisible.

The pre-compiled CSS from @xds/core/dist/xds.css is already minified,
so CSS minification in the report build is unnecessary.
cixzhang added a commit that referenced this pull request Apr 26, 2026
… breakage (#623)

LightningCSS lowers CSS light-dark() into polyfill variables
(--lightningcss-light/--lightningcss-dark) that are never initialized,
silently breaking all XDS theming colors. This has bitten us 3 separate
times (PRs #558, #566, #499) across different Vite configs.

Changes:
- apps/example-vite/vite.config.ts: add build.cssMinify: false
- apps/storybook/vite.config.ts: add build.cssMinify: false
- apps/example-vite/README.md: add lightningcss gotcha as top entry,
  detailed explanation section, and update inline config example
- apps/example-nextjs/README.md: add awareness note (Next.js uses
  PostCSS so not directly affected, but warn about custom minifiers)

Co-authored-by: Navi <navi@users.noreply.github.com>
cixzhang added a commit that referenced this pull request Jun 21, 2026
)

LightningCSS was lowering native light-dark() into polyfill variables
(--lightningcss-light/--lightningcss-dark) despite browser targets being
set. These polyfill variables are never initialized in the report,
causing all theme colors to be invisible.

The pre-compiled CSS from @xds/core/dist/xds.css is already minified,
so CSS minification in the report build is unnecessary.
cixzhang added a commit that referenced this pull request Jun 21, 2026
… breakage (#623)

LightningCSS lowers CSS light-dark() into polyfill variables
(--lightningcss-light/--lightningcss-dark) that are never initialized,
silently breaking all XDS theming colors. This has bitten us 3 separate
times (PRs #558, #566, #499) across different Vite configs.

Changes:
- apps/example-vite/vite.config.ts: add build.cssMinify: false
- apps/storybook/vite.config.ts: add build.cssMinify: false
- apps/example-vite/README.md: add lightningcss gotcha as top entry,
  detailed explanation section, and update inline config example
- apps/example-nextjs/README.md: add awareness note (Next.js uses
  PostCSS so not directly affected, but warn about custom minifiers)

Co-authored-by: Navi <navi@users.noreply.github.com>
cixzhang added a commit that referenced this pull request Jun 21, 2026
)

LightningCSS was lowering native light-dark() into polyfill variables
(--lightningcss-light/--lightningcss-dark) despite browser targets being
set. These polyfill variables are never initialized in the report,
causing all theme colors to be invisible.

The pre-compiled CSS from @xds/core/dist/xds.css is already minified,
so CSS minification in the report build is unnecessary.
cixzhang added a commit that referenced this pull request Jun 21, 2026
… breakage (#623)

LightningCSS lowers CSS light-dark() into polyfill variables
(--lightningcss-light/--lightningcss-dark) that are never initialized,
silently breaking all XDS theming colors. This has bitten us 3 separate
times (PRs #558, #566, #499) across different Vite configs.

Changes:
- apps/example-vite/vite.config.ts: add build.cssMinify: false
- apps/storybook/vite.config.ts: add build.cssMinify: false
- apps/example-vite/README.md: add lightningcss gotcha as top entry,
  detailed explanation section, and update inline config example
- apps/example-nextjs/README.md: add awareness note (Next.js uses
  PostCSS so not directly affected, but warn about custom minifiers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant