Skip to content

Instantly share code, notes, and snippets.

@Bhacaz
Last active April 30, 2025 23:30
Show Gist options
  • Save Bhacaz/db7124f379857c94d62c1c32f19d07de to your computer and use it in GitHub Desktop.
Save Bhacaz/db7124f379857c94d62c1c32f19d07de to your computer and use it in GitHub Desktop.
DaisyUI with Tailwind-cli / standalone

Important

Only for Tailwind 3 and DaisyUI 4.

For DaisyUI 5, simply follow the official documentation.

The goal is to eliminate Node.js (including jsbundling and cssbundling) as a dependency when using tailwindcss-rails.

The approach involves downloading and bundling DaisyUI once, allowing Tailwind CLI to handle the rest of the compilation, avoiding the need for Node.js tools, as suggested in this issue.

Another reference.

The following script will:

  1. Install DaisyUI via npm.
  2. Bundle it under ./lib/daisyui/daisyui-VERSION.js.
  3. Clean up the Node.js files and folders afterward, as they will no longer be needed.
#!/usr/bin/env sh
npm i daisyui esbuild
daisyuiVersion=$(npm list daisyui --depth=0 --json | grep '"version"' | cut -d '"' -f 4)
npx esbuild ./node_modules/daisyui/src/index.js --bundle --platform=node --outfile=lib/daisyui/daisyui-$daisyuiVersion.js
# Cleanup
rm -fr node_modules
rm package.json
rm package-lock.json
# Output
echo "Add require('../lib/daisyui/daisyui-$daisyuiVersion') into your tailwind.config.js"
@yshmarov
Copy link

I don't think this would work for Tailwind 4

@Bhacaz
Copy link
Author

Bhacaz commented Apr 30, 2025

I don't think this would work for Tailwind 4

You're right, that was for Tailwind 3 and DaisyUI 4. I'll precise it. Thanks

DaisyUI 5 has the documentation to use a bundled file: https://daisyui.com/docs/install/rails

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment