tailwind css cannot be used in the module
I added a hook to introduce tailwind but didn't seem to take effect
/modules/hello/runtime/components tailwind components use in the name of the class is still not effective.
2 Replies
Hi @S22y. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The knowledge sources do not mention using the
@tailwindcss/vite plugin directly in a Nuxt module or via a Vite hook. Instead, the recommended way to enable Tailwind CSS in a Nuxt module is to use Nuxt's built-in module system and the official @nuxtjs/tailwindcss module.
To add Tailwind CSS support in your custom Nuxt module, you should use the installModule utility from @nuxt/kit to install @nuxtjs/tailwindcss and configure it as needed. Here is an example from the official documentation:
This approach ensures that Tailwind CSS is properly integrated into the Nuxt build process and will work for components in your module. Using the Vite plugin directly is not the recommended or supported way in Nuxt, and may not work as expected because Nuxt manages Vite and Tailwind integration internally through its module system Using Other Modules in Your Module.
If you follow this pattern and Tailwind classes are still not effective, double-check that your CSS file includes the Tailwind directives and that the content paths include your module's components.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@386803087471542272> Kapa.ai is still learning and improving, please let me know how I did by reacting below.