tailwindcss-rails 4.0.0.rc3 → 4.0.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12604797b6ffc0e9448b859c4b25511065fc86dd28c1479d9a48186ac7b2cfd1
|
4
|
+
data.tar.gz: b908633069e894863319afa7f3ea64737e47e906d17f257e02763548cca1d2c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f95003629c04627ceef411f2def2cb09d4a7f3d9452d5be2ed1871d8912f7ceb16a3db49948f444e5c2d67d1cf8dac3ccca17425eb7b15b2cd2395acd4ab61ce
|
7
|
+
data.tar.gz: c2f5deca8a2eb716ed9d006d318268640e5f83894302111eeb648afdd861834ad732dfc387ad0985eabecf4570b35f68e8b77871399c8fb293da499861e7e533
|
data/README.md
CHANGED
@@ -13,6 +13,7 @@
|
|
13
13
|
* [You don't _have_ to upgrade](#you-dont-_have_-to-upgrade)
|
14
14
|
* [Upgrade steps](#upgrade-steps)
|
15
15
|
* [Troubleshooting](#troubleshooting)
|
16
|
+
* [Updating CSS class names for v4](#updating-css-class-names-for-v4)
|
16
17
|
- [Developing with Tailwindcss](#developing-with-tailwindcss)
|
17
18
|
* [Configuration and commands](#configuration-and-commands)
|
18
19
|
* [Building for production](#building-for-production)
|
@@ -91,18 +92,47 @@ gem "tailwindcss-ruby", "~> 3.4"
|
|
91
92
|
|
92
93
|
First, update to `tailwindcss-rails` v4.0.0 or higher. This will also ensure you're transitively depending on `tailwindcss-ruby` v4.
|
93
94
|
|
94
|
-
|
95
|
+
|
96
|
+
```html
|
95
97
|
# Gemfile
|
96
98
|
gem "tailwindcss-rails", "~> 4.0" # which transitively pins tailwindcss-ruby to v4
|
97
99
|
```
|
98
100
|
|
99
|
-
|
101
|
+
If you want to migrate class names for v4 (optional), apply this [step](#upgrading-class-names-for-v4) and continue this guide.
|
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)
|
109
|
+
|
110
|
+
Then create a ``package.json`` in the root of the project:
|
111
|
+
|
112
|
+
```jsonc
|
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.
|
100
130
|
|
101
131
|
Here's what the upgrade task does:
|
102
132
|
|
103
133
|
- Cleans up some things in the generated `config/tailwind.config.js`.
|
104
134
|
- If present, moves `config/postcss.config.js` to the root directory.
|
105
|
-
- If present, moves `app/assets/stylesheets/application.tailwind.css` to `app/assets/tailwind`.
|
135
|
+
- If present, moves `app/assets/stylesheets/application.tailwind.css` to `app/assets/tailwind/application.css`.
|
106
136
|
- Removes unnecessary `stylesheet_link_tag "tailwindcss"` tags from the application layout.
|
107
137
|
- Removes references to the Inter font from the application layout.
|
108
138
|
- Runs the upstream upgrader (note: requires `npx` to run the one-time upgrade, but highly recommended).
|
@@ -119,22 +149,22 @@ $ bin/rails tailwindcss:upgrade
|
|
119
149
|
gsub app/views/layouts/application.html.erb
|
120
150
|
Remove unnecessary stylesheet_link_tag from application layout
|
121
151
|
gsub app/views/layouts/application.html.erb
|
122
|
-
Moving application.tailwind.css to /home/user/myapp/app/assets/tailwind
|
123
|
-
create app/assets/tailwind/application.
|
152
|
+
Moving /home/user/myapp/app/assets/stylesheets/application.tailwind.css to /home/user/myapp/app/assets/tailwind/application.css
|
153
|
+
create app/assets/tailwind/application.css
|
124
154
|
remove app/assets/stylesheets/application.tailwind.css
|
125
155
|
10.9.0
|
126
156
|
Running the upstream Tailwind CSS upgrader
|
127
157
|
run npx @tailwindcss/upgrade@next --force --config /home/user/myapp/config/tailwind.config.js from "."
|
128
158
|
≈ tailwindcss v4.0.0
|
129
159
|
│ Searching for CSS files in the current directory and its subdirectories…
|
130
|
-
│ ↳ Linked `./config/tailwind.config.js` to `./app/assets/tailwind/application.
|
160
|
+
│ ↳ Linked `./config/tailwind.config.js` to `./app/assets/tailwind/application.css`
|
131
161
|
│ Migrating JavaScript configuration files…
|
132
162
|
│ ↳ The configuration file at `./config/tailwind.config.js` could not be automatically migrated to the new CSS
|
133
163
|
│ configuration format, so your CSS has been updated to load your existing configuration file.
|
134
164
|
│ Migrating templates…
|
135
165
|
│ ↳ Migrated templates for configuration file: `./config/tailwind.config.js`
|
136
166
|
│ Migrating stylesheets…
|
137
|
-
│ ↳ Migrated stylesheet: `./app/assets/tailwind/application.
|
167
|
+
│ ↳ Migrated stylesheet: `./app/assets/tailwind/application.css`
|
138
168
|
│ ↳ No PostCSS config found, skipping migration.
|
139
169
|
│ Updating dependencies…
|
140
170
|
│ Could not detect a package manager. Please manually update `tailwindcss` to v4.
|
@@ -145,9 +175,9 @@ $ bin/rails tailwindcss:upgrade
|
|
145
175
|
Done in 56ms
|
146
176
|
run bundle install --quiet
|
147
177
|
```
|
148
|
-
|
149
178
|
</details>
|
150
179
|
|
180
|
+
|
151
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)!
|
152
182
|
|
153
183
|
|
@@ -157,21 +187,45 @@ You may want to check out [TailwindCSS v4 - upgrade experience report · rails/t
|
|
157
187
|
|
158
188
|
We know there are some cases we haven't addressed with the upgrade task:
|
159
189
|
|
160
|
-
- If the user isn’t using PostCSS, some migrations (e.g., updating class names in the view files) may fail
|
161
190
|
- 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
191
|
|
163
192
|
We'll try to improve the upgrade process over time, but for now you may need to do some manual work to upgrade.
|
164
193
|
|
165
194
|
|
195
|
+
### Updating CSS class names for v4
|
196
|
+
|
197
|
+
Before running the upgrade task, go to ``config/tailwind.config.js`` update the ``content`` part to:
|
198
|
+
|
199
|
+
```js
|
200
|
+
content: [
|
201
|
+
'../public/*.html',
|
202
|
+
'../app/helpers/**/*.rb',
|
203
|
+
'../app/javascript/**/*.js',
|
204
|
+
'../app/views/**/*.{erb,haml,html,slim}'
|
205
|
+
],
|
206
|
+
```
|
207
|
+
(Just add an additional ``.`` to all the paths referenced)
|
208
|
+
|
209
|
+
Run the upstream upgrader as instructed above.
|
210
|
+
|
211
|
+
Then, once you've run that successfully:
|
212
|
+
|
213
|
+
- **Delete** ``package.json``, ``node_modules/`` and ``package-lock.json`` (or ``yarn.lock``), plus remove ``/node_modules`` from ``.gitignore``.
|
214
|
+
- **Go** to your CSS file and remove the following line (if present):
|
215
|
+
```css
|
216
|
+
@plugin '@tailwindcss/container-queries';
|
217
|
+
```
|
218
|
+
|
219
|
+
|
166
220
|
## Developing with Tailwindcss
|
167
221
|
|
168
222
|
### Configuration and commands
|
169
223
|
|
170
|
-
#### Input file: `app/assets/tailwind/application.
|
224
|
+
#### Input file: `app/assets/tailwind/application.css`
|
171
225
|
|
172
|
-
The `tailwindcss:install` task will generate a Tailwind input file in `app/assets/tailwind/application.
|
226
|
+
The `tailwindcss:install` task will generate a Tailwind input file in `app/assets/tailwind/application.css`. This is where you import the plugins you want to use and where you can setup your custom `@apply` rules.
|
173
227
|
|
174
|
-
⚠ The location of this file changed in v4, from `app/assets/stylesheets` to `app/assets/tailwind`. The `tailwindcss:upgrade` task will move it for you.
|
228
|
+
⚠ The location of this file changed in v4, from `app/assets/stylesheets/application.tailwind.css` to `app/assets/tailwind/application.css`. The `tailwindcss:upgrade` task will move it for you.
|
175
229
|
|
176
230
|
#### Output file: `app/assets/builds/tailwind.css`
|
177
231
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
APPLICATION_LAYOUT_PATH = Rails.root.join("app/views/layouts/application.html.erb")
|
2
2
|
CENTERING_CONTAINER_INSERTION_POINT = /^\s*<%= yield %>/.freeze
|
3
|
-
TAILWIND_ASSET_PATH = Rails.root.join("app/assets/tailwind")
|
3
|
+
TAILWIND_ASSET_PATH = Rails.root.join("app/assets/tailwind/application.css")
|
4
4
|
|
5
5
|
if APPLICATION_LAYOUT_PATH.exist?
|
6
6
|
unless File.read(APPLICATION_LAYOUT_PATH).match?(/stylesheet_link_tag :app/)
|
@@ -32,9 +32,9 @@ if Rails.root.join(".gitignore").exist?
|
|
32
32
|
append_to_file(".gitignore", %(\n/app/assets/builds/*\n!/app/assets/builds/.keep\n))
|
33
33
|
end
|
34
34
|
|
35
|
-
unless TAILWIND_ASSET_PATH.
|
36
|
-
say "Add default #{TAILWIND_ASSET_PATH}
|
37
|
-
copy_file "#{__dir__}/application.
|
35
|
+
unless TAILWIND_ASSET_PATH.exist?
|
36
|
+
say "Add default #{TAILWIND_ASSET_PATH}"
|
37
|
+
copy_file "#{__dir__}/application.css", TAILWIND_ASSET_PATH
|
38
38
|
end
|
39
39
|
|
40
40
|
if Rails.root.join("Procfile.dev").exist?
|
@@ -1,8 +1,8 @@
|
|
1
1
|
TAILWIND_CONFIG_PATH = Rails.root.join("config/tailwind.config.js")
|
2
2
|
APPLICATION_LAYOUT_PATH = Rails.root.join("app/views/layouts/application.html.erb")
|
3
3
|
POSTCSS_CONFIG_PATH = Rails.root.join("config/postcss.config.js")
|
4
|
-
OLD_TAILWIND_ASSET_PATH = Rails.root.join("app/assets/stylesheets")
|
5
|
-
TAILWIND_ASSET_PATH = Rails.root.join("app/assets/tailwind")
|
4
|
+
OLD_TAILWIND_ASSET_PATH = Rails.root.join("app/assets/stylesheets/application.tailwind.css")
|
5
|
+
TAILWIND_ASSET_PATH = Rails.root.join("app/assets/tailwind/application.css")
|
6
6
|
|
7
7
|
unless TAILWIND_CONFIG_PATH.exist?
|
8
8
|
say "Default tailwind.config.js is missing!", :red
|
@@ -38,10 +38,10 @@ else
|
|
38
38
|
say %( Please check your layouts and remove any "inter-font" stylesheet links.)
|
39
39
|
end
|
40
40
|
|
41
|
-
if OLD_TAILWIND_ASSET_PATH.
|
42
|
-
say "Moving
|
43
|
-
copy_file OLD_TAILWIND_ASSET_PATH
|
44
|
-
remove_file OLD_TAILWIND_ASSET_PATH
|
41
|
+
if OLD_TAILWIND_ASSET_PATH.exist?
|
42
|
+
say "Moving #{OLD_TAILWIND_ASSET_PATH} to #{TAILWIND_ASSET_PATH}"
|
43
|
+
copy_file OLD_TAILWIND_ASSET_PATH, TAILWIND_ASSET_PATH
|
44
|
+
remove_file OLD_TAILWIND_ASSET_PATH
|
45
45
|
end
|
46
46
|
|
47
47
|
if system("npx --version")
|
data/lib/tailwindcss/commands.rb
CHANGED
@@ -8,7 +8,7 @@ module Tailwindcss
|
|
8
8
|
|
9
9
|
command = [
|
10
10
|
Tailwindcss::Ruby.executable(**kwargs),
|
11
|
-
"-i", rails_root.join("app/assets/tailwind/application.
|
11
|
+
"-i", rails_root.join("app/assets/tailwind/application.css").to_s,
|
12
12
|
"-o", rails_root.join("app/assets/builds/tailwind.css").to_s,
|
13
13
|
]
|
14
14
|
|
data/lib/tailwindcss/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.rc4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
@@ -64,7 +64,7 @@ files:
|
|
64
64
|
- lib/generators/tailwindcss/scaffold/templates/partial.html.erb.tt
|
65
65
|
- lib/generators/tailwindcss/scaffold/templates/show.html.erb.tt
|
66
66
|
- lib/install/Procfile.dev
|
67
|
-
- lib/install/application.
|
67
|
+
- lib/install/application.css
|
68
68
|
- lib/install/dev
|
69
69
|
- lib/install/install_tailwindcss.rb
|
70
70
|
- lib/install/upgrade_tailwindcss.rb
|
File without changes
|