tailwindcss-rails 4.3.0 → 4.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2520a011b4bef6255ee93a06b90ca76482ac3cf38236f6031226336033794220
4
- data.tar.gz: 89df63d397c8ebaf774129cc9cda90291d1cff0f7bcc29ff55230925c697f7aa
3
+ metadata.gz: 37b4470776d372044cf70aff35b3dbdb1296d445d683aef89ef13e8f4c7aa510
4
+ data.tar.gz: a782697028ed250f6aa001c46316afa71d0900371f818604804df436f9f79b58
5
5
  SHA512:
6
- metadata.gz: fff813245fc1a40d53f4a14e264dbd50a7c6312be4507e60d334d8da8da38e3f67bdf258a642db045e56847bd71cb114680b81bf3925995ae03157db51e36f53
7
- data.tar.gz: 750be07cbd111aae1c7f2746f58c3b3ec9db86812eb06099130e279bd10f92897e201caed26c44597280d9c64942465f7822f56897fbe2bcc3235b2a82a04369
6
+ metadata.gz: 929e43dae3a11d929bfb104e66dc7b9fc4b3788e50202adc9f31a40d306a51c105a5d15e279713ca82a857d97383ab08d035ebc4d64c101f1a714e7c49898a70
7
+ data.tar.gz: bca8090e90b84f01260fd3c23c6b3c28cbfca8311fcbb65fc22aa9141283ff532723f00a8cd2a0988d3b181f2863ee74025abc581ffaf50a67ac273bab587403
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Tailwind CSS for Rails
2
2
 
3
- [Tailwind CSS](https://tailwindcss.com) is a utility-first CSS framework packed with classes like flex, pt-4, text-center and rotate-90 that can be composed to build any design, directly in your markup.
3
+ [Tailwind CSS](https://tailwindcss.com) is a utility-first CSS framework packed with classes like `flex`, `pt-4`, `text-center` and `rotate-90` that can be composed to build any design, directly in your markup.
4
+
5
+ > [!NOTE]
6
+ > This document is specific to Tailwind v4, corresponding to v4 of this gem. If you are looking for documentation for v3, please visit to the [tailwindcss-rails v3
7
+ README](https://github.com/rails/tailwindcss-rails/tree/v3-stable?tab=readme-ov-file).
4
8
 
5
9
  <!-- regenerate TOC with `rake format:toc` -->
6
10
 
@@ -14,7 +18,7 @@
14
18
  * [Upgrade steps](#upgrade-steps)
15
19
  * [Troubleshooting a v4 upgrade](#troubleshooting-a-v4-upgrade)
16
20
  * [Updating CSS class names for v4](#updating-css-class-names-for-v4)
17
- - [Developing with Tailwindcss](#developing-with-tailwindcss)
21
+ - [Developing with TailwindCSS](#developing-with-tailwindcss)
18
22
  * [Configuration and commands](#configuration-and-commands)
19
23
  * [Building for production](#building-for-production)
20
24
  * [Building for testing](#building-for-testing)
@@ -26,6 +30,7 @@
26
30
  * [Rails Engines support (Experimental)](#rails-engines-support-experimental)
27
31
  - [Troubleshooting](#troubleshooting)
28
32
  * [The `watch` command is hanging](#the-watch-command-is-hanging)
33
+ * [The `build` command (or `bin/rails assets:precompile`) is hanging inside a docker container](#the-build-command-or-binrails-assetsprecompile-is-hanging-inside-a-docker-container)
29
34
  * [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)
30
35
  * [Running in a docker container exits prematurely](#running-in-a-docker-container-exits-prematurely)
31
36
  * [Conflict with sassc-rails](#conflict-with-sassc-rails)
@@ -43,7 +48,7 @@ With Rails 7 you can generate a new application preconfigured with Tailwind CSS
43
48
  1. Run `./bin/bundle add tailwindcss-rails`
44
49
  2. Run `./bin/rails tailwindcss:install`
45
50
 
46
- This gem depends on the `tailwindcss-ruby` gem to install a working Tailwind CLI executable.
51
+ This gem depends on the `tailwindcss-ruby` gem to install a working TailwindCSS CLI executable.
47
52
 
48
53
  ### Choosing a specific version of `tailwindcss`
49
54
 
@@ -238,7 +243,7 @@ Then, once you've run that successfully, clean up:
238
243
  ```
239
244
  - **Revert** the changes to `config/tailwind.config.js` so that paths are once again relative to the application root.
240
245
 
241
- ## Developing with Tailwindcss
246
+ ## Developing with TailwindCSS
242
247
 
243
248
  ### Configuration and commands
244
249
 
@@ -261,12 +266,13 @@ Synopsis:
261
266
  - `bin/rails tailwindcss:install` - installs the configuration file, output file, and `Procfile.dev`
262
267
  - `bin/rails tailwindcss:build` - generate the output file
263
268
  - `bin/rails tailwindcss:build[debug]` - generate unminimized output
269
+ - `bin/rails tailwindcss:build[verbose]` - emit the commands being run
264
270
  - `bin/rails tailwindcss:watch` - start live rebuilds, generating output on file changes
265
271
  - `bin/rails tailwindcss:watch[debug]` - generate unminimized output
266
- - `bin/rails tailwindcss:watch[poll]` - for systems without file system events
267
272
  - `bin/rails tailwindcss:watch[always]` - for systems without TTY (e.g., some docker containers)
273
+ - `bin/rails tailwindcss:watch[verbose]` - emit the commands being run
268
274
 
269
- Note that you can combine task options, e.g. `rails tailwindcss:watch[debug,poll]`.
275
+ Note that you can combine task options, e.g. `rails tailwindcss:watch[debug,always]`.
270
276
 
271
277
  This gem also makes available a Puma plugin to manage a live rebuild process when you run `rails server` (see "Live Rebuild" section below).
272
278
 
@@ -311,14 +317,6 @@ and then running `rails server` (or just `puma`) will run the Tailwind watch pro
311
317
 
312
318
  This is a flexible command, which can be run with a few different options.
313
319
 
314
- If you are running `rails tailwindcss:watch` on a system that doesn't fully support file system events, pass a `poll` argument to the task to instruct tailwindcss to instead use polling:
315
-
316
- ```
317
- rails tailwindcss:watch[poll]
318
- ```
319
-
320
- (If you use `bin/dev` then you should modify your `Procfile.dev` to use the `poll` option.)
321
-
322
320
  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.
323
321
 
324
322
  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`.
@@ -354,35 +352,12 @@ Than use `@plugin` annotation in `app/assets/tailwind/application.css`:
354
352
 
355
353
  ### Using with PostCSS
356
354
 
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.
358
-
359
- For example, to enable nesting:
360
-
361
- ```js
362
- // postcss.config.js
363
- export default {
364
- plugins: {
365
- "@tailwindcss/postcss": {},
366
- },
367
- };
368
- ```
369
-
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:
371
-
372
- ```json
373
- // package.json
374
- {
375
- "name": "my app",
376
- "private": true,
377
- "dependencies": {
378
- "@tailwindcss/postcss": "^4.0.0",
379
- "tailwindcss": "^4.0.0",
380
- "postcss": "^8.5.1"
381
- }
382
- }
383
- ```
355
+ > [!NOTE]
356
+ > Starting with Tailwind v4, the upstream CLI tool no longer supports PostCSS, and the `--postcss` option has
357
+ been removed. If you want to leverage PostCSS with Tailwind 3, please reference the [tailwindcss-rails v3
358
+ README](https://github.com/rails/tailwindcss-rails/tree/v3-stable?tab=readme-ov-file#using-with-postcss).
384
359
 
385
- Then you can use yarn or npm to install the dependencies.
360
+ To leverage PostCSS with Tailwind 4, please reference [The official Tailwind 4 PostCSS docs](https://tailwindcss.com/docs/installation/using-postcss), and leverage [cssbundling-rails](https://github.com/rails/cssbundling-rails).
386
361
 
387
362
  ### Custom inputs or outputs
388
363
 
@@ -428,6 +403,10 @@ There is a [known issue](https://github.com/tailwindlabs/tailwindcss/issues/1724
428
403
 
429
404
  Please try uninstalling `watchman` and try running the watch task again.
430
405
 
406
+ ### The `build` command (or `bin/rails assets:precompile`) is hanging inside a docker container
407
+
408
+ Without a `WORKDIR`, tailwind may search the entire filesystem for files with CSS class names. So, please make sure your Dockerfile uses a `WORKDIR`.
409
+
431
410
  ### Lost keystrokes or hanging when using terminal-based debugging tools (e.g. IRB, Pry, `ruby/debug`...etc.) with the Puma plugin
432
411
 
433
412
  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.
@@ -4,10 +4,9 @@ module TestUnit # :nodoc:
4
4
  module Generators # :nodoc:
5
5
  class ScaffoldGenerator < Base # :nodoc:
6
6
  def fix_system_test
7
- if turbo_defined? && options[:system_tests]
8
- gsub_file File.join("test/system", class_path, "#{file_name.pluralize}_test.rb"),
9
- /(click_on.*Destroy this.*)$/,
10
- "accept_confirm { \\1 }"
7
+ system_test_file = File.join("test/system", class_path, "#{file_name.pluralize}_test.rb")
8
+ if turbo_defined? && options[:system_tests] && File.exist?(system_test_file)
9
+ gsub_file(system_test_file, /(click_on.*Destroy this.*)$/, "accept_confirm { \\1 }")
11
10
  end
12
11
  end
13
12
 
@@ -13,14 +13,18 @@ Puma::Plugin.create do
13
13
  # If we use system(*command) instead, IRB and Debug can't read from $stdin
14
14
  # correctly bacause some keystrokes will be taken by watch_command.
15
15
  begin
16
- IO.popen(Tailwindcss::Commands.watch_command, 'r+') do |io|
16
+ IO.popen(['bin/rails', 'tailwindcss:watch'], 'r+') do |io|
17
17
  IO.copy_stream(io, $stdout)
18
18
  end
19
19
  rescue Interrupt
20
20
  end
21
21
  end
22
22
 
23
- launcher.events.on_stopped { stop_tailwind }
23
+ if Gem::Version.new(Puma::Const::PUMA_VERSION) >= Gem::Version.new("7")
24
+ launcher.events.after_stopped { stop_tailwind }
25
+ else
26
+ launcher.events.on_stopped { stop_tailwind }
27
+ end
24
28
 
25
29
  in_background do
26
30
  monitor_tailwind
@@ -21,11 +21,10 @@ module Tailwindcss
21
21
  command
22
22
  end
23
23
 
24
- def watch_command(always: false, poll: false, **kwargs)
24
+ def watch_command(always: false, **kwargs)
25
25
  compile_command(**kwargs).tap do |command|
26
26
  command << "-w"
27
27
  command << "always" if always
28
- command << "-p" if poll
29
28
  end
30
29
  end
31
30
 
@@ -1,6 +1,6 @@
1
1
  module Tailwindcss
2
2
  module Engines
3
- class << self
3
+ class << self
4
4
  def bundle
5
5
  FileUtils.mkdir_p(Rails.root.join("app/assets/builds/tailwind"))
6
6
  Rails::Engine.subclasses.select do |engine|
@@ -1,3 +1,3 @@
1
1
  module Tailwindcss
2
- VERSION = "4.3.0"
2
+ VERSION = "4.4.0"
3
3
  end
data/lib/tasks/build.rake CHANGED
@@ -14,11 +14,10 @@ namespace :tailwindcss do
14
14
  desc "Watch and build your Tailwind CSS on file changes"
15
15
  task watch: [:environment, :engines] do |_, args|
16
16
  debug = args.extras.include?("debug")
17
- poll = args.extras.include?("poll")
18
17
  always = args.extras.include?("always")
19
18
  verbose = args.extras.include?("verbose")
20
19
 
21
- command = Tailwindcss::Commands.watch_command(always: always, debug: debug, poll: poll)
20
+ command = Tailwindcss::Commands.watch_command(always: always, debug: debug)
22
21
  env = Tailwindcss::Commands.command_env(verbose: verbose)
23
22
  puts "Running: #{Shellwords.join(command)}" if verbose
24
23
 
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.3.0
4
+ version: 4.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  - !ruby/object:Gem::Version
112
112
  version: 3.2.0
113
113
  requirements: []
114
- rubygems_version: 3.6.7
114
+ rubygems_version: 3.6.9
115
115
  specification_version: 4
116
116
  summary: Integrate Tailwind CSS with the asset pipeline in Rails.
117
117
  test_files: []