Skip to content

Instantly share code, notes, and snippets.

@Bhacaz
Created August 23, 2024 00:10
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

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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment