You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, update to `tailwindcss-rails` v4.0.0 or higher. This will also ensure you're transitively depending on `tailwindcss-ruby` v4.
93
95
94
-
```html
96
+
97
+
```html
95
98
# Gemfile
96
99
gem "tailwindcss-rails", "~> 4.0" # which transitively pins tailwindcss-ruby to v4
97
100
```
98
101
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.
102
+
If you want to migrate class names for v4 (optional), apply this [step](#upgrading-class-names-for-v4) and continue this guide.
103
+
104
+
Add the following line to the `.gitignore` file:
105
+
106
+
```gitignore
107
+
/node_modules
108
+
```
109
+
(So the Tailwind update tool won’t dig through your node_modules files and infer incorrect migrations, because it complies with ``.gitignore`` constraints)
110
+
111
+
Then create a ``package.json`` in the root of the project:
112
+
113
+
```jsonc
114
+
{
115
+
"name":"app_name",
116
+
"version":"1.0.0",
117
+
"dependencies": {
118
+
"tailwindcss":"^3.4.17", // Mandatory!!
119
+
// Install all plugins and modules that are referenced in tailwind.config.js
120
+
"@tailwindcss/aspect-ratio":"^0.4.2",
121
+
"@tailwindcss/container-queries":"^0.1.1",
122
+
"@tailwindcss/forms":"^0.5.10",
123
+
"@tailwindcss/typography":"^0.5.16"
124
+
// And so on...
125
+
}
126
+
}
127
+
```
128
+
**Run**``npm install`` (or ``yarn install`` if using ``yarn``)
129
+
130
+
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.
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)!
152
187
153
188
@@ -157,12 +192,36 @@ You may want to check out [TailwindCSS v4 - upgrade experience report · rails/t
157
192
158
193
We know there are some cases we haven't addressed with the upgrade task:
159
194
160
-
- If the user isn’t using PostCSS, some migrations (e.g., updating class names in the view files) may fail
161
195
- 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.
162
196
163
197
We'll try to improve the upgrade process over time, but for now you may need to do some manual work to upgrade.
164
198
165
199
200
+
### Updating CSS class names for v4
201
+
202
+
Before running the upgrade task, go to ``config/tailwind.config.js`` update the ``content`` part to:
203
+
204
+
```js
205
+
content: [
206
+
'../public/*.html',
207
+
'../app/helpers/**/*.rb',
208
+
'../app/javascript/**/*.js',
209
+
'../app/views/**/*.{erb,haml,html,slim}'
210
+
],
211
+
```
212
+
(Just add an additional ``.`` to all the paths referenced)
213
+
214
+
Run the upstream upgrader as instructed above.
215
+
216
+
Then, once you've run that successfully:
217
+
218
+
- **Delete** ``package.json``, ``node_modules/`` and ``package-lock.json`` (or ``yarn.lock``), plus remove ``/node_modules`` from ``.gitignore``.
219
+
- **Go** to your CSS file and remove the following line (if present):
0 commit comments