Fix PatternFly v6 component CSS not loading - #534
Merged
Conversation
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
approved these changes
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
.mjsmodules in@patternfly/react-stylesthatimport './component.css'. Thepackage marks only
*.cssassideEffects, but not the.mjsfiles that import them. Webpack treats those
.mjsfiles asside-effect-free and drops the CSS imports during tree-shaking.
Fix: add a webpack rule forcing
@patternfly/react-styles/*.mjsto be treated as side-effectful so the CSS imports are preserved.
ISSUE TYPE
COMPONENT NAME
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.