How to install Tailwind CSS and daisyUI in a Electron project
Initialize a new Node project
entry point
should bemain.js
mkdir myapp
cd myapp
npm init
Run this command to add the required scripts to yourpackage.json
npm pkg set scripts.start="electron ."
npm pkg set scripts.build:css="tailwindcss -i src/input.css -o public/output.css"
npm install electron tailwindcss@latest @tailwindcss/cli@latest daisyui@latest
Create amain.js
at the root of your project with the following content
const { app, BrowserWindow } = require('electron')
const createWindow = () => {
const win = new BrowserWindow()
win.loadFile('src/index.html')
}
app.whenReady().then(() => {
createWindow()
})
Create asrc/index.html
file with the following content
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<link rel="stylesheet" type="text/css" href="../public/output.css">
</head>
<body>
<button class="btn">Hello daisyUI</button>
</body>
</html>
Create asrc/input.css
file with the following content
@import "tailwindcss";
@plugin "daisyui";
npm run build:css
npm start
Now you can use daisyUI class names!