tailwindcss-rails 4.0.0.rc5 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +65 -49
- data/lib/tailwindcss/version.rb +1 -1
- metadata +14 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30675a62d715227df3d53c507a3f20b95d1a7ec993d5dc58a5a346d687cb732f
|
4
|
+
data.tar.gz: 5d48adc3bd62d127bcb5618d3156ac6e7c1413acace42fc804df2d1e4eb17fe3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b145598cdc5c279835e5e9f03ca8905b74d5da65d865e276eb5c4d53b6af8e1a491dceec08b0720789c3bc873839ab19b4bee31cd306224e308dc3cab3df998f
|
7
|
+
data.tar.gz: 249e0738be704d1bc886bc20cb001a1345b5e4b1b562a3bcda91cd27ab72c9a22af4ca26de1f2502a00e8d1697a1006c30b932a27bf562d3c23c63896fe4cb68
|
data/README.md
CHANGED
@@ -35,17 +35,17 @@
|
|
35
35
|
|
36
36
|
## Installation
|
37
37
|
|
38
|
-
With Rails 7 you can generate a new application preconfigured with Tailwind by using `--css tailwind`. If you're adding Tailwind later, you need to:
|
38
|
+
With Rails 7 you can generate a new application preconfigured with Tailwind CSS by using `--css tailwind`. If you're adding Tailwind later, you need to:
|
39
39
|
|
40
40
|
1. Run `./bin/bundle add tailwindcss-rails`
|
41
41
|
2. Run `./bin/rails tailwindcss:install`
|
42
42
|
|
43
|
-
This gem depends on the `tailwindcss-ruby` gem to install a working
|
43
|
+
This gem depends on the `tailwindcss-ruby` gem to install a working Tailwind CLI executable.
|
44
44
|
|
45
45
|
|
46
46
|
### Choosing a specific version of `tailwindcss`
|
47
47
|
|
48
|
-
The `tailwindcss-ruby` gem is declared as a floating dependency of this gem, so by default you will get the most recent stable version. However, you can select a specific version of
|
48
|
+
The `tailwindcss-ruby` gem is declared as a floating dependency of this gem, so by default you will get the most recent stable version. However, you can select a specific version of Tailwind CSS by pinning that gem to the analogous version in your application's `Gemfile`. For example,
|
49
49
|
|
50
50
|
``` ruby
|
51
51
|
gem "tailwindcss-rails"
|
@@ -63,72 +63,53 @@ You can also use a local (npm-based) installation if you prefer, please go to ht
|
|
63
63
|
|
64
64
|
v4.x of this gem has been updated to work with Tailwind v4, including providing some help with upgrading your application.
|
65
65
|
|
66
|
-
A full explanation of a Tailwind v4 upgrade is out of scope for this README, so we strongly urge you to read the [official Tailwind v4 upgrade guide](https://tailwindcss.com/docs/upgrade-guide) before embarking on an upgrade to an existing large app.
|
66
|
+
A full explanation of a Tailwind CSS v4 upgrade is out of scope for this README, so we **strongly urge** you to read the [official Tailwind CSS v4 upgrade guide](https://tailwindcss.com/docs/upgrade-guide) before embarking on an upgrade to an existing large app.
|
67
67
|
|
68
|
-
This gem will help with some of the mechanics of the upgrade
|
68
|
+
This gem will help with some of the mechanics of the upgrade:
|
69
|
+
|
70
|
+
- update some generated files to handle breaking changes in v4 of this gem,
|
71
|
+
- update some local project files to meet some Tailwind CSS v4 conventions,
|
72
|
+
- attempt to run the [upstream v4 upgrade tool](https://tailwindcss.com/docs/upgrade-guide#using-the-upgrade-tool).
|
69
73
|
|
70
74
|
|
71
75
|
### You don't _have_ to upgrade
|
72
76
|
|
73
|
-
Keep in mind that you don't _need_ to upgrade. You can stay on Tailwind v3 for the foreseeable future if you prefer not to migrate now, or if your migration runs into problems.
|
77
|
+
Keep in mind that you don't _need_ to upgrade. You can stay on Tailwind CSS v3 for the foreseeable future if you prefer not to migrate now, or if your migration runs into problems.
|
74
78
|
|
75
|
-
|
79
|
+
If you don't want to upgrade, then pin your application to v3.3.1 of this gem:
|
76
80
|
|
77
81
|
``` ruby
|
78
82
|
# Gemfile
|
79
|
-
gem "tailwindcss-rails", "3.3.1" # which transitively pins tailwindcss-ruby to v3
|
83
|
+
gem "tailwindcss-rails", "~> 3.3.1" # which transitively pins tailwindcss-ruby to v3
|
80
84
|
```
|
81
85
|
|
82
|
-
|
86
|
+
If you're on an earlier version of this gem, `<= 3.3.0`, then make sure you're pinning the version of **both** `tailwindcss-rails` and `tailwindcss-ruby`:
|
83
87
|
|
84
88
|
``` ruby
|
85
89
|
# Gemfile
|
86
90
|
gem "tailwindcss-rails", "~> 3.3"
|
87
|
-
gem "tailwindcss-ruby", "~> 3.4"
|
91
|
+
gem "tailwindcss-ruby", "~> 3.4" # only necessary with tailwindcss-rails <= 3.3.0
|
88
92
|
```
|
89
93
|
|
90
94
|
|
91
95
|
### Upgrade steps
|
92
96
|
|
93
|
-
|
97
|
+
> [!WARNING]
|
98
|
+
> In applications using Tailwind plugins without JavaScript tooling, these upgrade steps may fail to fully migrate `tailwind.config.js` because the upstream upgrade tool needs the Tailwind plugins to be installed and available through a JavaScript package manager. If you see errors from the upstream upgrade tool, you should try following the additional steps in [Updating CSS class names for v4](#updating-css-class-names-for-v4) which will help you install (temporarily!) the necessary packages and clean up afterwards.
|
94
99
|
|
100
|
+
First, update to `tailwindcss-rails` v4.0.0 or higher. This will also ensure you're transitively depending on `tailwindcss-ruby` v4.
|
95
101
|
|
96
102
|
```html
|
97
103
|
# Gemfile
|
98
104
|
gem "tailwindcss-rails", "~> 4.0" # which transitively pins tailwindcss-ruby to v4
|
99
105
|
```
|
100
106
|
|
101
|
-
If you want to migrate class names for v4 (optional),
|
102
|
-
|
103
|
-
Add the following line to the `.gitignore` file:
|
104
|
-
|
105
|
-
```gitignore
|
106
|
-
/node_modules
|
107
|
-
```
|
108
|
-
(So the Tailwind update tool won’t dig through your node_modules files and infer incorrect migrations, because it complies with ``.gitignore`` constraints)
|
107
|
+
If you want to migrate CSS class names for v4 (this is an optional step!), jump to [Updating CSS class names for v4](#updating-css-class-names-for-v4) before continuing.
|
109
108
|
|
110
|
-
Then
|
109
|
+
Then, run `bin/rails tailwindcss:upgrade`. 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.
|
111
110
|
|
112
|
-
|
113
|
-
|
114
|
-
"name": "app_name",
|
115
|
-
"version": "1.0.0",
|
116
|
-
"dependencies": {
|
117
|
-
"tailwindcss": "^3.4.17", // Mandatory!!
|
118
|
-
// Install all plugins and modules that are referenced in tailwind.config.js
|
119
|
-
"@tailwindcss/aspect-ratio": "^0.4.2",
|
120
|
-
"@tailwindcss/container-queries": "^0.1.1",
|
121
|
-
"@tailwindcss/forms": "^0.5.10",
|
122
|
-
"@tailwindcss/typography": "^0.5.16"
|
123
|
-
// And so on...
|
124
|
-
}
|
125
|
-
}
|
126
|
-
```
|
127
|
-
**Run** ``npm install`` (or ``yarn install`` if using ``yarn``)
|
128
|
-
|
129
|
-
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.
|
130
|
-
|
131
|
-
Here's what the upgrade task does:
|
111
|
+
<details>
|
112
|
+
<summary>Here's a detailed list of what the upgrade task does.</summary>
|
132
113
|
|
133
114
|
- Cleans up some things in the generated `config/tailwind.config.js`.
|
134
115
|
- If present, moves `config/postcss.config.js` to the root directory.
|
@@ -137,6 +118,8 @@ Here's what the upgrade task does:
|
|
137
118
|
- Removes references to the Inter font from the application layout.
|
138
119
|
- Runs the upstream upgrader (note: requires `npx` to run the one-time upgrade, but highly recommended).
|
139
120
|
|
121
|
+
</details>
|
122
|
+
|
140
123
|
<details>
|
141
124
|
<summary>Here's what that upgrade looks like on a vanilla Rails app.</summary>
|
142
125
|
|
@@ -178,7 +161,7 @@ Done in 56ms
|
|
178
161
|
</details>
|
179
162
|
|
180
163
|
|
181
|
-
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)
|
164
|
+
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) and try following the additional steps in [Updating CSS class names for v4](#updating-css-class-names-for-v4).
|
182
165
|
|
183
166
|
|
184
167
|
### Troubleshooting
|
@@ -187,14 +170,45 @@ You may want to check out [TailwindCSS v4 - upgrade experience report · rails/t
|
|
187
170
|
|
188
171
|
We know there are some cases we haven't addressed with the upgrade task:
|
189
172
|
|
190
|
-
- In
|
173
|
+
- In applications using Tailwind plugins without JavaScript tooling, these upgrade steps may fail to fully migrate `tailwind.config.js` because the upstream upgrade tool needs the Tailwind plugins to be installed and available through a JavaScript package manager. If you see errors from the upstream upgrade tool, you should try following the additional steps in [Updating CSS class names for v4](#updating-css-class-names-for-v4) which will help you install (temporarily!) the necessary packages and clean up afterwards.
|
191
174
|
|
192
175
|
We'll try to improve the upgrade process over time, but for now you may need to do some manual work to upgrade.
|
193
176
|
|
194
177
|
|
195
178
|
### Updating CSS class names for v4
|
196
179
|
|
197
|
-
|
180
|
+
> [!NOTE]
|
181
|
+
> If you'd like to help automate these steps, please drop a note to the maintainers in [this discussion thread](https://github.com/rails/tailwindcss-rails/discussions/450).
|
182
|
+
|
183
|
+
With some additional manual work the upstream upgrade tool will update your application's CSS class names to v4 conventions. **This is an optional step that requires a JavaScript toolchain.**
|
184
|
+
|
185
|
+
**Add** the following line to the `.gitignore` file, to prevent the upstream upgrade tool from accessing node_modules files.
|
186
|
+
|
187
|
+
```gitignore
|
188
|
+
/node_modules
|
189
|
+
```
|
190
|
+
|
191
|
+
**Create** a `package.json` in the root of the project:
|
192
|
+
|
193
|
+
```jsonc
|
194
|
+
{
|
195
|
+
"name": "app_name",
|
196
|
+
"version": "1.0.0",
|
197
|
+
"dependencies": {
|
198
|
+
"tailwindcss": "^3.4.17", // Mandatory!!
|
199
|
+
// Install all plugins and modules that are referenced in tailwind.config.js
|
200
|
+
"@tailwindcss/aspect-ratio": "^0.4.2",
|
201
|
+
"@tailwindcss/container-queries": "^0.1.1",
|
202
|
+
"@tailwindcss/forms": "^0.5.10",
|
203
|
+
"@tailwindcss/typography": "^0.5.16"
|
204
|
+
// And so on...
|
205
|
+
}
|
206
|
+
}
|
207
|
+
```
|
208
|
+
|
209
|
+
**Run** `npm install` (or `yarn install` if using `yarn`)
|
210
|
+
|
211
|
+
**Update** `config/tailwind.config.js` and temporarily change the `content` part to have an additional `.` on all paths so they are relative to the config file:
|
198
212
|
|
199
213
|
```js
|
200
214
|
content: [
|
@@ -204,17 +218,19 @@ Before running the upgrade task, go to ``config/tailwind.config.js`` update the
|
|
204
218
|
'../app/views/**/*.{erb,haml,html,slim}'
|
205
219
|
],
|
206
220
|
```
|
207
|
-
(Just add an additional ``.`` to all the paths referenced)
|
208
221
|
|
209
|
-
|
222
|
+
(Just add an additional `.` to all the paths referenced)
|
223
|
+
|
224
|
+
**Run** the upstream upgrader as instructed above.
|
210
225
|
|
211
|
-
Then, once you've run that successfully:
|
226
|
+
Then, once you've run that successfully, clean up:
|
212
227
|
|
213
|
-
- **Delete**
|
228
|
+
- **Delete** `package.json`, `node_modules/` and `package-lock.json` (or `yarn.lock`), plus remove `/node_modules` from `.gitignore`.
|
214
229
|
- **Go** to your CSS file and remove the following line (if present):
|
215
230
|
```css
|
216
231
|
@plugin '@tailwindcss/container-queries';
|
217
232
|
```
|
233
|
+
- **Revert** the changes to `config/tailwind.config.js` so that paths are once again relative to the application root.
|
218
234
|
|
219
235
|
|
220
236
|
## Developing with Tailwindcss
|
@@ -311,7 +327,7 @@ Running `bin/dev` invokes Foreman to start both the Tailwind watch process and t
|
|
311
327
|
|
312
328
|
### Using with PostCSS
|
313
329
|
|
314
|
-
If you want to use PostCSS as a preprocessor, create a custom `postcss.config.js` in your project root directory, and that file will be loaded by
|
330
|
+
If you want to use PostCSS as a preprocessor, create a custom `postcss.config.js` in your project root directory, and that file will be loaded by Tailwind automatically.
|
315
331
|
|
316
332
|
For example, to enable nesting:
|
317
333
|
|
@@ -324,7 +340,7 @@ export default {
|
|
324
340
|
}
|
325
341
|
```
|
326
342
|
|
327
|
-
⚠ Note that PostCSS is a
|
343
|
+
⚠ Note that PostCSS is a JavaScript tool with its own prerequisites! By default `tailwindcss-rails` does not require any JavaScript tooling, so in order to use PostCSS, a `package.json` with dependencies for your plugins and a package manager like `yarn` or `npm` is required, for example:
|
328
344
|
|
329
345
|
```json
|
330
346
|
// package.json
|
data/lib/tailwindcss/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tailwindcss-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-01
|
11
|
+
date: 2025-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -86,7 +86,17 @@ licenses:
|
|
86
86
|
metadata:
|
87
87
|
homepage_uri: https://github.com/rails/tailwindcss-rails
|
88
88
|
rubygems_mfa_required: 'true'
|
89
|
-
post_install_message:
|
89
|
+
post_install_message: |+
|
90
|
+
== Upgrading to Tailwind CSS v4 ==
|
91
|
+
|
92
|
+
If you are upgrading to tailwindcss-rails 4.x, please read the upgrade guide at:
|
93
|
+
|
94
|
+
https://github.com/rails/tailwindcss-rails/blob/main/README.md#upgrading-your-application-from-tailwind-v3-to-v4
|
95
|
+
|
96
|
+
If you're not ready to upgrade yet, please pin to version 3 in your Gemfile:
|
97
|
+
|
98
|
+
gem "tailwindcss-rails", "~> 3.3.1"
|
99
|
+
|
90
100
|
rdoc_options: []
|
91
101
|
require_paths:
|
92
102
|
- lib
|
@@ -106,3 +116,4 @@ signing_key:
|
|
106
116
|
specification_version: 4
|
107
117
|
summary: Integrate Tailwind CSS with the asset pipeline in Rails.
|
108
118
|
test_files: []
|
119
|
+
...
|