The team is now working on the WordPress Interactivity API. This unblocks the same UX Frontity framework enabled but directly in WordPress Core, fully compatible with the new Site Editor.
You can now use Tailwind classes with your preferred CSS-in-JS library by importing tailwind.macro :
import {styled} from 'frontity'
import tw from 'tailwind.macro'
const Button = styled('button')` ${tw`font-mono text-sm text-red hover:text-blue`}; `
Itās possible to do somethink like that?
Iāve tried but Iām getting the following error:
MacroError: The macro you imported from āundefinedā is being executed outside the context of compilation with babel-plugin-macros. This indicates that you donāt have the babel plugin ābabel-plugin-macrosā configured correctly. Please see the documentation for how to configure babel-plugin-macros properly: https://github.com/kentcdodds/babel-plugin-macros/blob/master/other/docs/user.md
I donāt have experience with babel plugins, so itās not immediately clear to me what the issue could be. Could you provide a small reproduction repo?
christian.nascimento3
I just wanna use tailwindcss with frontity styled. Itās supposed to work with any CSS-in-JS.
They recommend two approaches:
1 - CSS-in-JS:
2 - Postcss
I have successful with Postcss but none with CSS-in-JS.
Sorry, Iāve realized that we do not support custom .babelrc files as far as I know. @luisherranz Could you confirm that for me?
luisherranz5
We donāt, but custom babel support is planed at both project and package level via the upcoming frontity.config.js file.
But maybe before that, we can add babel-plugin-macros to the core babel configuration. Iām going to study if it makes sense, thanks for the suggestion @christian.nascimento!
1 Like
luisherranz6
I think it makes total sense to add babel-plugin-macros to our core babel packages. Iāll add a feature request for that.
By the way, this is extremely simple to do but we have a ton of things with higher priority in the roadmap. If you want to collaborate and submit a pull request yourself, I will gladly instruct you how and merge the code.
WARNING: After adding/removing dependencies to a package, go back to the root and do npm install again.
If you are doing modifications to the packages that run before webpack, like file-settings , babel-plugin-frontity or the scripts of core , you need to run npm run build in that package folder after each change.
2 Likes
luisherranz11
Iāve just merged a pull request from wisammechano that includes the babel-macros-plugin in Frontity
It will be released with the next version of Frontity.
5 Likes
christian.nascimento12
OMG! I was planning to create a pull request this week. This is awesome! Thanks @luisherranz!
1 Like
luisherranz13
The babel-macros-plugin was included in the last release.
@christian.nascimento could you please let us know if you are able to use it with Tailwind?
1 Like
dejangeorgiev14
Hi guys, thank you very much for adding babel-macros-plugin!
I am also trying to use it with Tailwindcss on twentytwenty-theme, unfortunately without success. @christian.nascimento, if possible, could you please share how you brought this to work.
Many thanks.
All the best,
Dejan
luisherranz15
Hey @dejangeorgiev, could you please provide more details of what is exactly what you are doing and what problems are you having? Thanks!
dejangeorgiev16
Hi @luisherranz, sure, i will share here with you.
Sorry for my delay! Yes Iām using with frontity. I created a repo with this example. I dont know if this is interesting to add in the frontity docs. What do you thing?
dejangeorgiev19
Hi @christian.nascimento, i am fine, thank you. Hope you too?
Thank you very much for creating this repo, just added the config to my script and works perferct! Great job!
Thank you.
Best regards,
Dejan
2 Likes
christian.nascimento20
This is amazing Thanks for the feedback!
Best regards,
Christian
1 Like
luisherranz23
This is awesome! Thanks @christian.nascimento
Pablo24
Thanks for this contribution @christian.nascimento