npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
./tailwind.config.js
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./resources/**/*.blade.php",
"./resources/**/*.js",
"./resources/**/*.vue",
],
theme: {
extend: {},
},
plugins: [],
}
./resources/css/app.css
@tailwind base;
@tailwind components;
@tailwind utilities;
例如 app.blade
,加入 @vite('resources/css/app.css')
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@vite('resources/css/app.css')
</head>
<body>
<h1 class="text-3xl font-bold underline">
Hello world!
</h1>
</body>
</html>
執行 php artisan server
或是 octane 時都要同時執行 vite 才會使 tailwindCSS 即時生效
npm run dev
npm run build