Skip to content

Fix PatternFly v6 component CSS not loading - #534

Merged
cigamit merged 1 commit into
ctrliq:mainfrom
blaipr:fix/pf6-css-tree-shaking
Jun 28, 2026
Merged

Fix PatternFly v6 component CSS not loading#534
cigamit merged 1 commit into
ctrliq:mainfrom
blaipr:fix/pf6-css-tree-shaking

Conversation

@blaipr

@blaipr blaipr commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

SUMMARY

PatternFly v6 component CSS was silently tree-shaken by webpack,
leaving only the base reset styles (205 rules instead of ~2800).
The login page, forms, buttons — all PF6 components rendered
without any layout or styling.

Root cause: PF6 ships per-component CSS via .mjs modules in
@patternfly/react-styles that import './component.css'. The
package marks only *.css as sideEffects, but not the .mjs
files that import them. Webpack treats those .mjs files as
side-effect-free and drops the CSS imports during tree-shaking.

Fix: add a webpack rule forcing @patternfly/react-styles/*.mjs
to be treated as side-effectful so the CSS imports are preserved.

ISSUE TYPE

  • Bug, Docs Fix or other nominal change

COMPONENT NAME

  • UI

ASCENDER VERSION

25.3.7.dev

ADDITIONAL INFORMATION

Regression introduced by the PF5 → PF6 upgrade (PRs #519/#520).
Before: 316 CSS rules loaded. After fix: 2792 CSS rules loaded.

PatternFly v6 ships per-component CSS via .mjs modules in
@patternfly/react-styles that import adjacent .css files
(e.g. `import './login.css'`). The package marks only *.css
as sideEffects in its package.json, but not the .mjs files
that import them. Webpack tree-shakes the .mjs → .css imports
away, leaving only the base reset styles (205 rules instead
of ~2800).

Add a webpack rule to force @patternfly/react-styles .mjs
files to be treated as side-effectful so the CSS imports
are preserved.
@cigamit cigamit self-assigned this Jun 28, 2026
@cigamit
cigamit merged commit 8ca7301 into ctrliq:main Jun 28, 2026
sy-base pushed a commit to sy-base/ascender that referenced this pull request Jul 4, 2026
PatternFly v6 ships per-component CSS via .mjs modules in
@patternfly/react-styles that import adjacent .css files
(e.g. `import './login.css'`). The package marks only *.css
as sideEffects in its package.json, but not the .mjs files
that import them. Webpack tree-shakes the .mjs → .css imports
away, leaving only the base reset styles (205 rules instead
of ~2800).

Add a webpack rule to force @patternfly/react-styles .mjs
files to be treated as side-effectful so the CSS imports
are preserved.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants