Replies: 5 comments 14 replies
-
@moshekatz Same. Not necessarily at that scale, but have the same problem. There are three options I see atm.
Thats all I can think of. Another potential option is having all the MFEs be packages and any app consuming a certain MFE would npm install that package just to simply have tailwind parse it to purge properly (this could be a decent option. Just haven't played with it). EDIT |
Beta Was this translation helpful? Give feedback.
-
I isolate every sub app. and inject the css file below the sub app. I use this solution:https://github.com/MinJieLiu/micro-app and style inject like: function createLink(href) {
const link = document.createElement("link");
link.rel = "stylesheet";
link.href = href;
return link;
}
defineApp.styleInject = (parentNode) => {
["./assets/style.cd5fecfe.css"].forEach((css) => {
const link = createLink(new URL(css, import.meta["url"]));
parentNode.prepend(link);
});
}; |
Beta Was this translation helpful? Give feedback.
-
Today I thought using the JIT CDN would be great for MFEs and then I found Twind which seems to be the perfect fit for my usecase. Before I was experimenting with option 1 of the original post. The problem was that in Tailwind the order of the classes actually matter a lot when it comes to variants so the style of hover:text-blue would be overwritten by another MFE loaded at a later point in time with the bare text-blue class because now .text-blue comes after the hover variant. I then decided to use postcss-class-prefixer with a custom prefix per MFE to scope the classes to the children of the root of the MFE. I did not like my solution because it was very brittle and hard to debug. Tailwind classes existed all over the place. And TW classes in the root app could not be easily scoped. I was at a point where I regretted using TW for my MFE project and thought that TW is not a great fit for MFEs in general. Compilation of TW classes on the client side could change that drastically. The benefit is that all my MFEs do not need to care about TW anymore and they all use the same styles automatically. I just define a styleguide in the root app via a custom tailwind config and be happy. |
Beta Was this translation helpful? Give feedback.
-
For Angular: https://ng-journal.com/blog/2022-12-02-tailwind-and-module-federation/ |
Beta Was this translation helpful? Give feedback.
-
currently the most nice solution for MFE is this one I think |
Beta Was this translation helpful? Give feedback.
-
Hey 👋,
I'm working on a large micro frontend app (50+ different repos, layout components shared across 99% of pages, custom shared components on multiple pages).
I was wondering how would you integrate tailwind in an efficient way.
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions