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
93
94
-
```html
94
+
```html
95
95
# Gemfile
96
96
gem "tailwindcss-rails", "~> 4.0" # which transitively pins tailwindcss-ruby to v4
97
97
```
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``)
98
135
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.
**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
+
151
197
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
198
153
199
@@ -157,7 +203,6 @@ You may want to check out [TailwindCSS v4 - upgrade experience report · rails/t
157
203
158
204
We know there are some cases we haven't addressed with the upgrade task:
159
205
160
-
- If the user isn’t using PostCSS, some migrations (e.g., updating class names in the view files) may fail
161
206
- 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
207
163
208
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