microeinhundert / radonis

Build monolithic applications with a modern, React-based frontend stack based on the Node.js MVC framework AdonisJS.
https://radonis.vercel.app/
MIT License
67 stars 2 forks source link

Unable to Add Tailwind With Daisy UI #45

Closed jordin-marshall closed 7 months ago

jordin-marshall commented 7 months ago

Description

With this not using webpack and I'm not sure how everything is being built with esbuild, how would one go about adding Tailwind w/ Daisy UI? For the life of me, I can't figure it out

Package Version

5.0.4

Error Message & Stack Trace

Relevant Information

microeinhundert commented 7 months ago

Radonis uses UnoCSS by default, which means DaisyUI would need a plugin which is compatible with UnoCSS. You can however just setup Tailwind like you would normally, and include the compiled Tailwind styles via ˋwithHeadTagsˋ. You would need to run the Tailwind CLI manually.

jordin-marshall commented 7 months ago

@microeinhundert So I'd have to add the following code to every Controller render return? There's currently no other way to include it on all pages?

.withHeadTags([{
        name: 'link href="css/custom.css"',
        content: '',
}])
microeinhundert commented 7 months ago

You can use a middleware.

jordin-marshall commented 7 months ago

Thank you for your quick responses, creating a middleware solved everything.

For anyone else who stumbles upon this while looking for a solution, the middleware "example" code is:

import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'

export default class AppendHeadTagsGlobal {
  async handle({ radonis }: HttpContextContract, next: () => Promise<void>) {
      await next();

      radonis.withHeadTags([
        {
          name: 'link rel="stylesheet" href="custom.css"',
          content: ''
        },
      ]);
  }
}
microeinhundert commented 7 months ago

You should add the attributes to the link tag via the "attributes" property, not as part of the name.