Skip to content

Commit d25b5cb

Browse files
committed
Update modular federation css header match pattern to catch production build
1 parent 3bd8f27 commit d25b5cb

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

web/components/providers/remote-extension-provider.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,21 @@ export default function RemoteExtensionProvider({
5454
// }, []);
5555

5656
useEffect(() => {
57-
const pattern = /__federation_expose_main\.globals\.css/;
57+
// Modify the href to point to an empty CSS file
58+
// to prevent federation module's css from loading
59+
// into the main app.
60+
//
61+
// This is a workaround for the issue where
62+
// the CSS from the federated module is loaded
63+
// into the main app and overrides the main app's CSS.
64+
65+
// TODO: Use mf-manifest.json to get the css file name
66+
const pattern = /\.css/;
5867
const observer = new MutationObserver((mutations) => {
5968
mutations.forEach((mutation) => {
6069
mutation.addedNodes.forEach((node) => {
6170
if (node instanceof HTMLLinkElement && pattern.test(node.href)) {
6271
console.warn("Removing federated CSS before it loads:", node.href);
63-
// Modify the href to point to an empty CSS file
64-
// to prevent federation module's css from loading
65-
// into the main app.
66-
//
67-
// This is a workaround for the issue where
68-
// the CSS from the federated module is loaded
69-
// into the main app and overrides the main app's CSS.
7072
node.href = "/empty.css";
7173
}
7274
});

0 commit comments

Comments
 (0)