I was having trouble with theme.json was not being generated during build. It looks like the theme layer generated by tailwind wraps the variables in :root and :host, which causes the function wordpressThemeJson to return without generating the theme.json. I was using an essentially a fresh build, and I did not extend the default tailwind theme. The fix is to change this line in resources/js/wordpress.js:
if (!themeContent.startsWith(':root{')) {
return;
}
to:
if (!themeContent.trim().startsWith(":root")) {
return;
}
Not sure what this is actually checking for, so i have no idea if this will cause issues.
I am having issues with the theme.json not being generated when using the latest code on main. Is there a way to get access to the tailwind v4 branch for testing?