[v4] Tailwind is not working in Wordpress React Block #16467
Replies: 3 comments
-
Hey there! From the output it seems like Tailwind CSS did not run at all on your config. There needs to be a build step where you call the Tailwind compiler via any of the integrations listed on our website: https://tailwindcss.com/docs/installation/using-vite This will be based specifically on your project setup so something that works with Wordpress React Blocks but I have not used that before so moving it to a discussion in case someone else has any idea! |
Beta Was this translation helpful? Give feedback.
-
I think I've got it solved. It's a bit tricky but it works.
"tailwind:build-editor": "find ./src -name 'editor.css' | while read file; do output=./build/${file#./src/}; output=${output%editor.css}index.css; mkdir -p \"$(dirname \"$output\")\"; npx tailwindcss -i \"$file\" -o \"$output\" --minify; done",
"tailwind:build": "find ./src -name 'style.css' | while read file; do output=./build/${file#./src/}; output=${output%style.css}style-index.css; mkdir -p \"$(dirname \"$output\")\"; npx tailwindcss -i \"$file\" -o \"$output\" --minify; done", Script will look for files editor.css in subdirectories (in case if there will be more than one block) and process the file to proper output. I'm doing the same for the style.css file
"build": "wp-scripts build --webpack-copy-php && npm run tailwind:build && npm run tailwind:build-editor", I didn't update watch scripts because I don't need them right now. |
Beta Was this translation helpful? Give feedback.
-
Please check these answers, maybe they will be helpful. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Like in the title.
Directory structure
Files content
package.json scripts
editor.css and/or style.css
in edit.js I'm importing css file
import './editor.css';
and I have mapped classes like it's described in docs
in render.php file I have sample div with class
py-4
After running build command I can see files in the /build directory. CSS file content
As you can see the classes are not generated. What am i missing?
Beta Was this translation helpful? Give feedback.
All reactions