SymfonyCasts / tailwind-bundle

Delightful Tailwind Support for Symfony + AssetMapper
https://symfony.com/bundles/TailwindBundle/current/index.html
MIT License
77 stars 16 forks source link

Use TailwindBundle with plugins #66

Open JuGid opened 1 day ago

JuGid commented 1 day ago

I am trying to use DaisyUI as a Tailwind plugin so I have a tailwind config file like this :

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    "./assets/**/*.js",
    "./templates/**/*.html.twig",
  ],
  theme: {
    extend: {},
  },
  plugins: [
    require('daisyui'),
  ],
}

But, after re-build, this doesn't work as expected since the page does not load the daisyUI css. Do I have to add something to the importmap ? I have installed DaisyUI as described here : https://daisyui.com/docs/install/

Also, when using TailwindUI free components like the navbar, the dropdowns stay open and I can't click to close them. Don't know if it's a related issue.

EDIT : This is my output when php bin/console tailwind:build

 Command:
    '/XXXX/var/tailwind/v3.4.13/tailwindcss-macos-x64' '-c' '/XXXX/tailwind.config.js' '-i' '/XXXX/assets/styles/app.css' '-o' '/XXXX/var/tailwind/app.built.css'

Rebuilding...

🌼   daisyUI 4.12.13
├─ ✔︎ 2 themes added             https://daisyui.com/docs/themes
╰─ ❤︎ Support daisyUI project:   https://opencollective.com/daisyui

Done in 995ms.
JuGid commented 1 day ago

EDIT : DaisyUI themes are not working when using the tailwind.config.js. That's really weird. Did I miss something ? And things like bg-primary is not working too

I found the solution digging the internet to use DaisyUI CSS. Btw, this is the full solution I found :

  1. Run npm i -D daisyui@latest
  2. Modify your tailwind.config.js
    /** @type {import('tailwindcss').Config} */
    module.exports = {
    content: [
    "./assets/**/*.js",
    "./templates/**/*.html.twig",
    "./node_modules/daisyui/**/*.js" // ADD THIS
    ],
    theme: {
    extend: {},
    },
    plugins: [
    require('daisyui'), // AND THIS
    ],
    }
  3. Run php bin/console importmap:require daisyui
  4. Optionally (?) : Run php bin/console asset-map:compile
  5. Then run php bin/console tailwind:build (with or without -w)

You're ready to go !

bocharsky-bw commented 20 hours ago

Hey @JuGid

Thanks for sharing your solution regarding DaisyUI with others! I personally haven't used DaisyUI before, so can't say much. But seems their installation docs are not complete? I don't see they mention adding "./node_modules/daisyui/**/*.js" in their https://daisyui.com/docs/install/ . Or probably that needed only for additional features (not all) so you had to add it in your specific case.

Anyway, as I see we can close this issue now, right? Also, if you see the ways to improve the docs here: https://symfony.com/bundles/TailwindBundle/current/index.html - please, feel free to create a PR and we will discuss it :)

JuGid commented 14 hours ago

Hey,

I'm sorry, I made an edit (which is not clear) that say :

EDIT : DaisyUI themes are not working when using the tailwind.config.js. That's really weird. Did I miss something ? And things like bg-primary is not working too

Please, donc close this issue since I have installed DaisyUI but some functionalities don't work 🥲

I will make some improvements to the documentation in the future but it's already great enough !

bocharsky-bw commented 12 minutes ago

For the themes, I think you may need to add more configuration according to their docs: https://daisyui.com/docs/themes/

I hope that helps