tw is not defined when using as in a library outside of a nextjs folder #790
-
I am following the guide for nextjs, and twin.macro works perfectly for when i want to use tailwind within the app folder (i am using the nx apps folder structure) But I am also using a shared library in a typical nx folder structure. So I update the webpack config like so:
When I import I have seen advice here about using rollup to build the library, but I think that is overkill because i am not making it a package, i just want to use it cross various apps within the application. Any advice appreciated Disclaimer: I am using module federation but the problem persists if I just run one app in my testing. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Sounds like a pickle! And I agree pre-building your ui-kit would be overkill here. I've actually run into this issue before and to solved it by using a plugin called Hope that helps a tad! |
Beta Was this translation helpful? Give feedback.
The withTwin.js setup is preferred as it allows babel to work alongside SWC - without it, Next.js disables SWC and only uses babel.
This isn't the worst, but there may be some speed improvements you're missing out on with a larger codebase.
Are you seeing a note in your terminal about that when you start the dev process?