tailwindcss-rails 4.2.3 → 4.3.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +37 -45
- data/lib/tailwindcss/engine.rb +4 -0
- data/lib/tailwindcss/engines.rb +23 -0
- data/lib/tailwindcss/version.rb +1 -1
- data/lib/tailwindcss-rails.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20ce264a20dac62cd290726a18023d0d9981012d6160ec39c177978249e60598
|
4
|
+
data.tar.gz: 1493673e3f6afa4651fe65bd14d5ea758bb76d672796907f3305f26c9fcd61d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f161431ed9e4c1fe1b89a72d3a29447b4ceb58846cf74562305437b4eb7b862b86bac45c4534ece4aeda954e905cc822feea70acdd53ada772ba0de4796e2193
|
7
|
+
data.tar.gz: cbb6dc145179678acef43e56baca61250a27c30030376b798e0d61dbd68fb19d3fa30fae1bc6e0c031ec5722747c37d07aea04d3ad97da025726b9d115733c4a
|
data/README.md
CHANGED
@@ -23,7 +23,9 @@
|
|
23
23
|
* [Using Tailwind plugins](#using-tailwind-plugins)
|
24
24
|
* [Using with PostCSS](#using-with-postcss)
|
25
25
|
* [Custom inputs or outputs](#custom-inputs-or-outputs)
|
26
|
+
* [Rails Engines support (Experimental)](#rails-engines-support-experimental)
|
26
27
|
- [Troubleshooting](#troubleshooting)
|
28
|
+
* [The `watch` command is hanging](#the-watch-command-is-hanging)
|
27
29
|
* [Lost keystrokes or hanging when using terminal-based debugging tools (e.g. IRB, Pry, `ruby/debug`...etc.) with the Puma plugin](#lost-keystrokes-or-hanging-when-using-terminal-based-debugging-tools-eg-irb-pry-rubydebugetc-with-the-puma-plugin)
|
28
30
|
* [Running in a docker container exits prematurely](#running-in-a-docker-container-exits-prematurely)
|
29
31
|
* [Conflict with sassc-rails](#conflict-with-sassc-rails)
|
@@ -43,12 +45,11 @@ With Rails 7 you can generate a new application preconfigured with Tailwind CSS
|
|
43
45
|
|
44
46
|
This gem depends on the `tailwindcss-ruby` gem to install a working Tailwind CLI executable.
|
45
47
|
|
46
|
-
|
47
48
|
### Choosing a specific version of `tailwindcss`
|
48
49
|
|
49
50
|
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,
|
50
51
|
|
51
|
-
```
|
52
|
+
```ruby
|
52
53
|
gem "tailwindcss-rails"
|
53
54
|
|
54
55
|
# pin to tailwindcss version 3.4.13
|
@@ -59,7 +60,6 @@ gem "tailwindcss-ruby", "3.4.13"
|
|
59
60
|
|
60
61
|
You can also use a local (npm-based) installation if you prefer, please go to https://github.com/flavorjones/tailwindcss-ruby for more information.
|
61
62
|
|
62
|
-
|
63
63
|
## Upgrading your application from Tailwind v3 to v4
|
64
64
|
|
65
65
|
v4.x of this gem has been updated to work with Tailwind v4, including providing some help with upgrading your application.
|
@@ -72,27 +72,25 @@ This gem will help with some of the mechanics of the upgrade:
|
|
72
72
|
- update some local project files to meet some Tailwind CSS v4 conventions,
|
73
73
|
- attempt to run the [upstream v4 upgrade tool](https://tailwindcss.com/docs/upgrade-guide#using-the-upgrade-tool).
|
74
74
|
|
75
|
-
|
76
75
|
### You don't _have_ to upgrade
|
77
76
|
|
78
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.
|
79
78
|
|
80
79
|
If you don't want to upgrade, then pin your application to v3.3.1 of this gem:
|
81
80
|
|
82
|
-
```
|
81
|
+
```ruby
|
83
82
|
# Gemfile
|
84
83
|
gem "tailwindcss-rails", "~> 3.3.1" # which transitively pins tailwindcss-ruby to v3
|
85
84
|
```
|
86
85
|
|
87
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`:
|
88
87
|
|
89
|
-
```
|
88
|
+
```ruby
|
90
89
|
# Gemfile
|
91
90
|
gem "tailwindcss-rails", "~> 3.3"
|
92
91
|
gem "tailwindcss-ruby", "~> 3.4" # only necessary with tailwindcss-rails <= 3.3.0
|
93
92
|
```
|
94
93
|
|
95
|
-
|
96
94
|
### Upgrade steps
|
97
95
|
|
98
96
|
> [!WARNING]
|
@@ -100,8 +98,8 @@ gem "tailwindcss-ruby", "~> 3.4" # only necessary with tailwindcss-rails <= 3.3.
|
|
100
98
|
|
101
99
|
First, update to `tailwindcss-rails` v4.0.0 or higher. This will also ensure you're transitively depending on `tailwindcss-ruby` v4.
|
102
100
|
|
103
|
-
```
|
104
|
-
# Gemfile
|
101
|
+
```ruby
|
102
|
+
# Gemfile
|
105
103
|
gem "tailwindcss-rails", "~> 4.0" # which transitively pins tailwindcss-ruby to v4
|
106
104
|
```
|
107
105
|
|
@@ -114,7 +112,7 @@ gem "tailwindcss-rails", "~> 4.0" # which transitively pins tailwindcss-ruby to
|
|
114
112
|
|
115
113
|
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.
|
116
114
|
|
117
|
-
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
|
115
|
+
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.
|
118
116
|
|
119
117
|
<details>
|
120
118
|
<summary>Here's a detailed list of what the upgrade task does.</summary>
|
@@ -131,7 +129,7 @@ Then, run `bin/rails tailwindcss:upgrade`. Among other things, this will try to
|
|
131
129
|
<details>
|
132
130
|
<summary>Here's what that upgrade looks like on a vanilla Rails app.</summary>
|
133
131
|
|
134
|
-
```
|
132
|
+
```sh
|
135
133
|
$ bin/rails tailwindcss:upgrade
|
136
134
|
apply /path/to/tailwindcss-rails/lib/install/upgrade_tailwindcss.rb
|
137
135
|
Removing references to 'defaultTheme' from /home/user/myapp/config/tailwind.config.js
|
@@ -166,12 +164,11 @@ $ bin/rails tailwindcss:upgrade
|
|
166
164
|
Done in 56ms
|
167
165
|
run bundle install --quiet
|
168
166
|
```
|
169
|
-
</details>
|
170
167
|
|
168
|
+
</details>
|
171
169
|
|
172
170
|
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).
|
173
171
|
|
174
|
-
|
175
172
|
### Troubleshooting a v4 upgrade
|
176
173
|
|
177
174
|
You may want to check out [TailwindCSS v4 - upgrade experience report · rails/tailwindcss-rails · Discussion #450](https://github.com/rails/tailwindcss-rails/discussions/450) if you're having trouble upgrading.
|
@@ -182,7 +179,6 @@ We know there are some cases we haven't addressed with the upgrade task:
|
|
182
179
|
|
183
180
|
We'll try to improve the upgrade process over time, but for now you may need to do some manual work to upgrade.
|
184
181
|
|
185
|
-
|
186
182
|
### Updating CSS class names for v4
|
187
183
|
|
188
184
|
> [!NOTE]
|
@@ -208,9 +204,9 @@ With some additional manual work the upstream upgrade tool will update your appl
|
|
208
204
|
"@tailwindcss/aspect-ratio": "^0.4.2",
|
209
205
|
"@tailwindcss/container-queries": "^0.1.1",
|
210
206
|
"@tailwindcss/forms": "^0.5.10",
|
211
|
-
"@tailwindcss/typography": "^0.5.16"
|
207
|
+
"@tailwindcss/typography": "^0.5.16",
|
212
208
|
// And so on...
|
213
|
-
}
|
209
|
+
},
|
214
210
|
}
|
215
211
|
```
|
216
212
|
|
@@ -280,12 +276,10 @@ This gem also generates a `Procfile.dev` file which will run both the rails serv
|
|
280
276
|
|
281
277
|
The `tailwindcss:build` is automatically attached to `assets:precompile`, so before the asset pipeline digests the files, the Tailwind output will be generated.
|
282
278
|
|
283
|
-
|
284
279
|
### Building for testing
|
285
280
|
|
286
281
|
The `tailwindcss:build` task is automatically attached to the `test:prepare` Rake task. This task runs before test commands. If you run `bin/rails test` in your CI environment, your Tailwind output will be generated before tests run.
|
287
282
|
|
288
|
-
|
289
283
|
### Building unminified assets
|
290
284
|
|
291
285
|
If you want unminified assets, you can:
|
@@ -303,7 +297,6 @@ While you're developing your application, you want to run Tailwind in "watch" mo
|
|
303
297
|
- or run `rails tailwindcss:watch` as a separate process,
|
304
298
|
- or run `bin/dev` which uses [Foreman](https://github.com/ddollar/foreman)
|
305
299
|
|
306
|
-
|
307
300
|
#### Puma plugin
|
308
301
|
|
309
302
|
This gem ships with a Puma plugin. To use it, add this line to your `puma.rb` configuration:
|
@@ -314,7 +307,6 @@ plugin :tailwindcss if ENV.fetch("RAILS_ENV", "development") == "development"
|
|
314
307
|
|
315
308
|
and then running `rails server` (or just `puma`) will run the Tailwind watch process in the background.
|
316
309
|
|
317
|
-
|
318
310
|
#### Run `rails tailwindcss:watch`
|
319
311
|
|
320
312
|
This is a flexible command, which can be run with a few different options.
|
@@ -331,38 +323,35 @@ If you are running `rails tailwindcss:watch` as a process in a Docker container,
|
|
331
323
|
|
332
324
|
If you are running `rails tailwindcss:watch` in a docker container without a tty, pass the `always` argument to the task to instruct tailwindcss to keep the watcher alive even when `stdin` is closed: `rails tailwindcss:watch[always]`. If you use `bin/dev` then you should modify your `Procfile.dev`.
|
333
325
|
|
334
|
-
|
335
326
|
#### Foreman
|
336
327
|
|
337
328
|
Running `bin/dev` invokes Foreman to start both the Tailwind watch process and the rails server in development mode based on your `Procfile.dev` file.
|
338
329
|
|
339
|
-
|
340
330
|
### Using Tailwind plugins
|
341
331
|
|
342
332
|
If you want to use Tailwind plugins, they can be installed using `package.json`.
|
343
333
|
|
344
334
|
Using Yarn:
|
345
335
|
|
346
|
-
```
|
336
|
+
```sh
|
347
337
|
[ ! -f package.json ] && yarn init
|
348
338
|
yarn add daisyui # example
|
349
339
|
```
|
350
340
|
|
351
341
|
Using npm:
|
352
342
|
|
353
|
-
```
|
343
|
+
```sh
|
354
344
|
npm init
|
355
345
|
npm add daisyui # example
|
356
346
|
```
|
357
347
|
|
358
348
|
Than use `@plugin` annotation in `app/assets/tailwind/application.css`:
|
359
349
|
|
360
|
-
```
|
350
|
+
```css
|
361
351
|
@import "tailwindcss";
|
362
352
|
@plugin "daisyui";
|
363
353
|
```
|
364
354
|
|
365
|
-
|
366
355
|
### Using with PostCSS
|
367
356
|
|
368
357
|
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.
|
@@ -374,8 +363,8 @@ For example, to enable nesting:
|
|
374
363
|
export default {
|
375
364
|
plugins: {
|
376
365
|
"@tailwindcss/postcss": {},
|
377
|
-
}
|
378
|
-
}
|
366
|
+
},
|
367
|
+
};
|
379
368
|
```
|
380
369
|
|
381
370
|
⚠ 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:
|
@@ -395,11 +384,18 @@ export default {
|
|
395
384
|
|
396
385
|
Then you can use yarn or npm to install the dependencies.
|
397
386
|
|
398
|
-
|
399
387
|
### Custom inputs or outputs
|
400
388
|
|
401
389
|
If you need to use a custom input or output file, you can run `bundle exec tailwindcss` to access the platform-specific executable, and give it your own build options.
|
402
390
|
|
391
|
+
### Rails Engines support (Experimental)
|
392
|
+
|
393
|
+
_This feature is experimental and may change in the future. If you have feedback, please join the [discussion](https://github.com/rails/tailwindcss-rails/discussions/355)._
|
394
|
+
|
395
|
+
If you have Rails Engines in your application that use Tailwind CSS and provide an `app/assets/tailwind/<engine_name>/engine.css` file, entry point files will be created for each of them in `app/assets/builds/tailwind/<engine_name>.css` so they can be included in your host application's Tailwind CSS by adding `@import "../builds/tailwind/<engine_name>"` to your `app/assets/tailwind/application.css` file.
|
396
|
+
|
397
|
+
> [!IMPORTANT]
|
398
|
+
> You must `@import` the engine CSS files in your `app/assets/tailwind/application.css` for the engine to be included in the build. By default, no engine CSS files are imported, and you must opt-in to using the file in your build.
|
403
399
|
|
404
400
|
## Troubleshooting
|
405
401
|
|
@@ -410,7 +406,7 @@ When having trouble with `tailwindcss:build` or `tailwindcss:watch`, the first t
|
|
410
406
|
|
411
407
|
Here's what that looks like:
|
412
408
|
|
413
|
-
```
|
409
|
+
```sh
|
414
410
|
$ bin/rails tailwindcss:build[verbose]
|
415
411
|
|
416
412
|
Running: /path/to/tailwindcss-ruby-4.0.17-x86_64-linux-gnu/exe/x86_64-linux-gnu/tailwindcss -i /home/flavorjones/code/oss/tailwindcss-rails/My Workspace/test-install/app/assets/tailwind/application.css -o /home/flavorjones/code/oss/tailwindcss-rails/My Workspace/test-install/app/assets/builds/tailwind.css --minify
|
@@ -432,34 +428,28 @@ There is a [known issue](https://github.com/tailwindlabs/tailwindcss/issues/1724
|
|
432
428
|
|
433
429
|
Please try uninstalling `watchman` and try running the watch task again.
|
434
430
|
|
435
|
-
|
436
431
|
### Lost keystrokes or hanging when using terminal-based debugging tools (e.g. IRB, Pry, `ruby/debug`...etc.) with the Puma plugin
|
437
432
|
|
438
433
|
We've addressed the issue and you can avoid the problem by upgrading `tailwindcss-rails` to [v2.4.1](https://github.com/rails/tailwindcss-rails/releases/tag/v2.4.1) or later versions.
|
439
434
|
|
440
|
-
|
441
435
|
### Running in a docker container exits prematurely
|
442
436
|
|
443
437
|
If you are running `rails tailwindcss:watch` as a process in a Docker container, set `tty: true` in `docker-compose.yml` for the appropriate container to keep the watch process running.
|
444
438
|
|
445
439
|
If you are running `rails tailwindcss:watch` in a docker container without a tty, pass the `always` argument to the task to instruct tailwindcss to keep the watcher alive even when `stdin` is closed: `rails tailwindcss:watch[always]`. If you use `bin/dev` then you should modify your `Procfile.dev`.
|
446
440
|
|
447
|
-
|
448
441
|
### Conflict with sassc-rails
|
449
442
|
|
450
443
|
Tailwind uses modern CSS features that are not recognized by the `sassc-rails` extension that was included by default in the Gemfile for Rails 6. In order to avoid any errors like `SassC::SyntaxError`, you must remove that gem from your Gemfile.
|
451
444
|
|
452
|
-
|
453
445
|
### Class names must be spelled out
|
454
446
|
|
455
447
|
For Tailwind to work, your class names need to be spelled out. If you need to make sure Tailwind generates class names that don't exist in your content files or that are programmatically composed, use the [safelist option](https://tailwindcss.com/docs/content-configuration#safelisting-classes).
|
456
448
|
|
457
|
-
|
458
449
|
### `ERROR: Cannot find the tailwindcss executable` for supported platform
|
459
450
|
|
460
451
|
See https://github.com/flavorjones/tailwindcss-ruby for help.
|
461
452
|
|
462
|
-
|
463
453
|
### Using asset-pipeline assets
|
464
454
|
|
465
455
|
In Rails, you want to use [assets from the asset pipeline to get fingerprinting](https://guides.rubyonrails.org/asset_pipeline.html#fingerprinting-versioning-with-digest-based-urls). However, Tailwind isn't aware of those assets.
|
@@ -468,20 +458,22 @@ To use assets from the pipeline, use `url(image.svg)`. [Since Sprockets v3.3.0](
|
|
468
458
|
|
469
459
|
```js
|
470
460
|
module.exports = {
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
}
|
461
|
+
theme: {
|
462
|
+
extend: {
|
463
|
+
backgroundImage: {
|
464
|
+
image: "url('image.svg')",
|
465
|
+
},
|
466
|
+
},
|
467
|
+
},
|
468
|
+
};
|
479
469
|
```
|
480
470
|
|
481
471
|
The inline version also works:
|
482
472
|
|
483
473
|
```html
|
484
|
-
<section class="bg-[url('image.svg')]">
|
474
|
+
<section class="bg-[url('image.svg')]">
|
475
|
+
Has the image as it's background
|
476
|
+
</section>
|
485
477
|
```
|
486
478
|
|
487
479
|
## License
|
data/lib/tailwindcss/engine.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Tailwindcss
|
2
|
+
module Engines
|
3
|
+
class << self
|
4
|
+
def bundle
|
5
|
+
FileUtils.mkdir_p(Rails.root.join("app/assets/builds/tailwind"))
|
6
|
+
Rails::Engine.subclasses.select do |engine|
|
7
|
+
engine.root.join("app/assets/tailwind/#{engine.engine_name}/engine.css").exist?
|
8
|
+
end.each do |engine|
|
9
|
+
file_path = Rails.root.join("app/assets/builds/tailwind/#{engine.engine_name}.css")
|
10
|
+
FileUtils.rm(file_path) if File.exist?(file_path)
|
11
|
+
template = <<~TEMPLATE
|
12
|
+
/* DO NOT MODIFY THIS FILE, it was auto-generated by tailwindcss-rails */
|
13
|
+
|
14
|
+
@import "#{engine.root.join("app/assets/tailwind/#{engine.engine_name}/engine.css")}";
|
15
|
+
TEMPLATE
|
16
|
+
File.open(file_path, 'w') do |file|
|
17
|
+
file.puts template
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/tailwindcss/version.rb
CHANGED
data/lib/tailwindcss-rails.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.
|
4
|
+
version: 4.3.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- lib/tailwindcss-rails.rb
|
74
74
|
- lib/tailwindcss/commands.rb
|
75
75
|
- lib/tailwindcss/engine.rb
|
76
|
+
- lib/tailwindcss/engines.rb
|
76
77
|
- lib/tailwindcss/upstream.rb
|
77
78
|
- lib/tailwindcss/version.rb
|
78
79
|
- lib/tasks/build.rake
|