Skip to content

Commit 7722abc

Browse files
committed
feat: upgrade from Tailwind v3 to v4
See Tailwind v4 breaking changes: https://tailwindcss.com/docs/upgrade-guide See Hugo's new integration with Tailwind v4: https://gohugo.io/functions/css/tailwindcss/ Close #3211
1 parent 1525b21 commit 7722abc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+4655
-1506
lines changed

.github/workflows/build-test-site.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ jobs:
3434
- recursive: false
3535
args: [--frozen-lockfile]
3636
37-
# - name: Install JS dependencies
38-
# run: rm -rf node_modules && pnpm install --frozen-lockfile
37+
- name: Install Tailwind v4 dependencies
38+
run: |
39+
cd modules/blox-tailwind
40+
pnpm install --frozen-lockfile
41+
cd ../..
3942
4043
- name: Check for linting errors
4144
run: pnpm run lint:js # TODO: also lint styles again once new rule errors resolved

modules/blox-bootstrap/layouts/_partials/page_metadata_authors.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
{{- if gt $index 0 }}, {{ end -}}
99
<span {{ if $highlight_name }}class="author-highlighted"{{end}}>
10-
{{/* Effectively check the page's `_build` option as `_build` is not exposed in Hugo's Page object. */}}
10+
{{/* Effectively check the page's `build` option as `build` is not exposed in Hugo's Page object. */}}
1111
{{- if .RelPermalink -}}
1212
<a href="{{.RelPermalink}}">{{.LinkTitle}}</a>
1313
{{- else -}}

modules/blox-tailwind/.npmrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# pnpm compatibility settings
2+
auto-install-peers=true
3+
strict-peer-dependencies=false
4+
public-hoist-pattern[]=*

modules/blox-tailwind/README.md

Lines changed: 57 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,67 @@
11
# Hugo Blox Tailwind UI
22

3-
The Hugo Blox web framework utilising [TailwindCSS](https://tailwindcss.com/) and its [typography plugin](https://tailwindcss.com/docs/typography-plugin) for styling components.
3+
The Hugo Blox web framework utilizing [Tailwind CSS v4](https://tailwindcss.com/) with Hugo's native integration for styling components with Tailwind v4.
44

5-
See the Blog Starter Template for an example using this module.
5+
## Requirements
66

7-
## Development
7+
- Hugo v0.148.2+ (Extended Edition)
8+
- Node.js v20+
9+
- pnpm (see `packageManager` field in package.json)
10+
11+
## Quick Start
12+
13+
### 1. Install Dependencies
814

915
```bash
10-
hugo mod npm pack
11-
npm install
16+
pnpm install
1217
```
1318

14-
You need to add this to your `config.yaml` to enable Hugo's Tailwind integration:
19+
### 2. Run Development Server
20+
21+
```bash
22+
hugo server
23+
```
24+
25+
Tailwind CSS is processed automatically by Hugo using the `css.TailwindCSS` function.
26+
27+
## Features
28+
29+
- **Tailwind CSS v4**: Latest version with improved performance over Tailwind v3
30+
- **Hugo Native Integration**: Uses Hugo's built-in `css.TailwindCSS` function
31+
- **Dynamic CSS Generation**: Only includes utilities actually used in your content for ultra-fast page loads
32+
- **No Pre-compilation**: CSS is generated on-demand (previously Tailwind v3 was pre-compiled in Hugo Blox as `wc.min.css`)
33+
- **Community Components**: Community components work seamlessly without manual compilation
34+
35+
## Configuration
36+
37+
The Tailwind configuration is now in CSS format at `assets/css/main.css` using the `@theme` directive. The configuration includes:
38+
39+
- Hugo Blox color schemes (primary, secondary, neutral)
40+
- Typography settings
41+
- Safelist patterns for dynamic classes
42+
- Dark mode support
43+
44+
## Migration from Tailwind v3
45+
46+
If you're upgrading from Tailwind v3:
47+
48+
1. Install the new dependencies: `pnpm install`
49+
2. Remove any `assets/dist/wc.min.css` files
50+
3. Add the `package.json` file from the latest starter templates
51+
4. Update your deployment scripts to install it with `pnpm install` (refer to the latest `.github` folder in the starters)
52+
5. The old `tailwind.config.js` and `postcss.config.js` files are no longer needed
53+
54+
## Development
55+
56+
For module development:
57+
58+
```bash
59+
# Install dependencies
60+
pnpm install
61+
62+
# Run development server
63+
hugo server --disableFastRender
1564

16-
```yaml
17-
build:
18-
writeStats: true
65+
# Build for production
66+
hugo --minify
1967
```

modules/blox-tailwind/assets/css/blox/navbar.css

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,15 @@ input#nav-toggle:checked ~ #nav-menu {
4141
}
4242

4343
.nav-link {
44-
@apply hover:text-primary-700 dark:hover:text-primary-300 dark:text-white block p-3 font-semibold transition lg:px-2 lg:py-3;
44+
@apply dark:text-white block p-3 font-semibold transition lg:px-2 lg:py-3;
45+
}
46+
47+
.nav-link:hover {
48+
color: rgb(var(--color-primary-700));
49+
}
50+
51+
.dark .nav-link:hover {
52+
color: rgb(var(--color-primary-300));
4553
}
4654

4755
.nav-dropdown {
@@ -63,9 +71,17 @@ input#nav-toggle:checked ~ #nav-menu {
6371
}
6472

6573
.nav-dropdown-item {
66-
@apply px-4 [&:not(:last-child)]:mb-2 dark:hover:bg-primary-500;
74+
@apply px-4 [&:not(:last-child)]:mb-2;
75+
}
76+
77+
.dark .nav-dropdown-item:hover {
78+
background-color: rgb(var(--color-primary-500));
6779
}
6880

6981
.nav-dropdown-link {
70-
@apply hover:text-primary-700 dark:text-white dark:hover:text-white block py-1 font-semibold transition;
82+
@apply dark:text-white dark:hover:text-white block py-1 font-semibold transition;
83+
}
84+
85+
.nav-dropdown-link:hover {
86+
color: rgb(var(--color-primary-700));
7187
}

modules/blox-tailwind/assets/css/chroma.css

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,12 @@
55
/* Requires relative position for Code Copy button */
66
.prose .chroma,
77
.prose pre {
8-
@apply relative rounded-md text-neutral-700 bg-neutral-50 dark:bg-slate-700 dark:text-white;
8+
@apply relative rounded-md dark:bg-slate-700 dark:text-white;
9+
color: rgb(var(--color-neutral-700));
10+
background-color: rgb(var(--color-neutral-50));
11+
}
12+
13+
.dark .prose .chroma,
14+
.dark .prose pre {
15+
color: white;
916
}

0 commit comments

Comments
 (0)