Skip to content

Commit 0ffd236

Browse files
committed
doc: update README with TailwindCSS v4 upgrade instructions
1 parent a180a29 commit 0ffd236

File tree

1 file changed

+49
-4
lines changed

1 file changed

+49
-4
lines changed

README.md

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,49 @@ gem "tailwindcss-ruby", "~> 3.4"
9191

9292
First, update to `tailwindcss-rails` v4.0.0 or higher. This will also ensure you're transitively depending on `tailwindcss-ruby` v4.
9393

94-
``` html
94+
```html
9595
# Gemfile
9696
gem "tailwindcss-rails", "~> 4.0" # which transitively pins tailwindcss-ruby to v4
9797
```
98+
To replace the class names accordingly for v4, go to ``config/tailwind.config.js`` update the ``content`` part to:
99+
100+
```js
101+
content: [
102+
'../public/*.html',
103+
'../app/helpers/**/*.rb',
104+
'../app/javascript/**/*.js',
105+
'../app/views/**/*.{erb,haml,html,slim}'
106+
],
107+
```
108+
(Just add an additional ``.`` to all the paths referenced)
109+
110+
Add the following line to the `.gitignore` file:
111+
112+
```gitignore
113+
/node_modules
114+
```
115+
(So the Tailwind update tool won’t dig through your node_modules files and infer incorrect migrations, because it complies with ``.gitignore`` constraints)
116+
117+
Then create a ``package.json`` in the root of the project:
118+
119+
```jsonc
120+
{
121+
"name": "app_name",
122+
"version": "1.0.0",
123+
"dependencies": {
124+
"tailwindcss": "^3.4.17", // Mandatory!!
125+
// Install all plugins and modules that are referenced in tailwind.config.js
126+
"@tailwindcss/aspect-ratio": "^0.4.2",
127+
"@tailwindcss/container-queries": "^0.1.1",
128+
"@tailwindcss/forms": "^0.5.10",
129+
"@tailwindcss/typography": "^0.5.16"
130+
// And so on...
131+
}
132+
}
133+
```
134+
**Run** ``npm install`` (or ``yarn install`` if using ``yarn``)
98135

99-
Then, run the `tailwindcss:upgrade` task. Among other things, this will try to run the official Tailwind upgrade utility. It requires `npx` in order to run, but it's a one-time operation and is *highly recommended* for a successful upgrade.
136+
Then, **run** the `tailwindcss:upgrade` task. Among other things, this will try to run the official Tailwind upgrade utility. It requires `npx` in order to run, but it's a one-time operation and is *highly recommended* for a successful upgrade.
100137

101138
Here's what the upgrade task does:
102139

@@ -145,9 +182,18 @@ $ bin/rails tailwindcss:upgrade
145182
Done in 56ms
146183
run bundle install --quiet
147184
```
148-
149185
</details>
150186
187+
188+
### Post Upgrade
189+
**Delete** ``package.json``, ``node_modules/`` and ``package-lock.json`` (or ``yarn.lock``), plus remove ``/node_modules`` from ``.gitignore``.
190+
191+
**Go** to your CSS file and remove the following line (if present):
192+
```css
193+
@plugin '@tailwindcss/container-queries';
194+
```
195+
196+
151197
If this doesn't succeed, it's likely that you've customized your Tailwind configuration and you'll need to do some work to make sure your application upgrades. Please read the [official upgrade guide](https://tailwindcss.com/docs/upgrade-guide)!
152198
153199
@@ -157,7 +203,6 @@ You may want to check out [TailwindCSS v4 - upgrade experience report · rails/t
157203
158204
We know there are some cases we haven't addressed with the upgrade task:
159205
160-
- If the user isn’t using PostCSS, some migrations (e.g., updating class names in the view files) may fail
161206
- In setups without JavaScript tooling, the update process may fail to fully migrate `tailwind.config.js` because the tool assumes that the imported packages (e.g., tailwind plugins) are installed via a package manager, allowing them to be called.
162207
163208
We'll try to improve the upgrade process over time, but for now you may need to do some manual work to upgrade.

0 commit comments

Comments
 (0)