Skip to content

Commit 047eb41

Browse files
committed
feat(blog): add guide for Tailwind CSS v4 setup script
Introduced a new blog post detailing a bash script to easily integrate Tailwind CSS v4 into Aurelia 2 projects using Vite and TypeScript. The script automates dependency installation and configuration updates, streamlining the setup process for developers.
1 parent bf00a39 commit 047eb41

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
+++
2+
title = "Adding Tailwind CSS v4 to Your Aurelia 2 + Vite + TypeScript Project with this Bash Script"
3+
authors = ["Dwayne Charrington"]
4+
description = "Adding Tailwind CSS v4 to Your Aurelia 2 + Vite + TypeScript project can be done in seconds with this bash script."
5+
date = 2025-01-23T12:00:00Z
6+
lastmod = 2025-01-23T12:00:00Z
7+
tags = ["bash", "scripts", "workflow"]
8+
+++
9+
10+
With the news of TailwindCSS v4 being released, I thought it would be a good time to share a bash script that will help you add TailwindCSS v4 to your Aurelia 2 + Vite + TypeScript project without having to worry about the setup and configuration.
11+
12+
This script will install the necessary dependencies, update the Vite config, and create the necessary CSS imports—so you can focus on design instead of setup. If you already have Tailwind configured, this script will not overwrite your existing configuration and is not for upgrading your existing Tailwind configuration.
13+
14+
Before we get started, make sure you have an Aurelia 2 project using Vite and TypeScript. If you don't, you can use simply run: `npx makes aurelia new-project-name -s typescript` (replacing `new-project-name` with the name of your project).
15+
16+
Once you have an Aurelia 2 project, you can run the script by running `./add-tailwind.sh` in the root of your project. Ensure the script is executable by running `chmod +x add-tailwind.sh`.
17+
18+
```bash
19+
#!/usr/bin/env bash
20+
21+
# 1. Install Tailwind CSS and the Vite plugin
22+
npm install -D tailwindcss @tailwindcss/vite
23+
24+
# 2. Add the Tailwind import to vite.config.ts if it's not already there
25+
# Mac/BSD `sed` uses the '' argument for in-place edits; on Linux, remove the extra ''
26+
if ! grep -q "import tailwindcss from '@tailwindcss/vite'" vite.config.ts; then
27+
sed -i '' "1i\\
28+
import tailwindcss from '@tailwindcss/vite'
29+
" vite.config.ts
30+
fi
31+
32+
# 3. Add `tailwindcss()` to the plugins array if it's missing
33+
if ! grep -q "tailwindcss()" vite.config.ts; then
34+
sed -i '' "s/plugins: \[/plugins: \[\\n tailwindcss(),/g" vite.config.ts
35+
fi
36+
37+
# 4. Ensure src/my-app.css exists and has the Tailwind import at the very top
38+
if [ ! -f ./src/my-app.css ]; then
39+
# If file doesn’t exist, create it with the Tailwind import
40+
cat <<EOF > ./src/my-app.css
41+
@import "tailwindcss";
42+
EOF
43+
echo "Created my-app.css with Tailwind import."
44+
else
45+
# If file exists but lacks the Tailwind import, add it at the very top
46+
if ! grep -q '@import "tailwindcss";' ./src/my-app.css; then
47+
sed -i '' '1 i\
48+
@import "tailwindcss";
49+
' ./src/my-app.css
50+
echo "Added Tailwind import to the top of my-app.css."
51+
else
52+
echo "my-app.css already has the Tailwind import."
53+
fi
54+
fi
55+
56+
echo "TailwindCSS setup complete!"
57+
```
58+
59+
Once the script completes, Tailwind v4 is installed, and your Aurelia project is configured to load Tailwind styles via Vite.

0 commit comments

Comments
 (0)