tailwindcss-rails 4.3.0 → 4.5.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: 286396c8100fdd62be9b92948d5ca9d7fa08f8b5747451f40f24405018ffe047
4
+ data.tar.gz: 937b6afa7441d470d2a0d8f10a21a409eff863d82f6c723ebe07a52d6d4ec462
5
5
  SHA512:
6
- metadata.gz: fff813245fc1a40d53f4a14e264dbd50a7c6312be4507e60d334d8da8da38e3f67bdf258a642db045e56847bd71cb114680b81bf3925995ae03157db51e36f53
7
- data.tar.gz: 750be07cbd111aae1c7f2746f58c3b3ec9db86812eb06099130e279bd10f92897e201caed26c44597280d9c64942465f7822f56897fbe2bcc3235b2a82a04369
6
+ metadata.gz: b1e3c2e086f51999a4541aba0de0a125c052e730a2fb13d302e00f4e688444abbb4bb1ba0858b4e6267951e8be70e7d37060558a6100c2fed37b71d399e23bb0
7
+ data.tar.gz: 6e1f8a07ec3502513a9cbadf05e5f2e51ffcd0d23415a3c1ff3d129994e43ffd21994194c84d0730fe93bac2c9e9a41cc34f1f282a085aca9dddd95abd09ad0c
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,15 @@ 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[silent]` - suppress non-error output from tailwindcss (requires Tailwind CSS v4.3.1)
270
+ - `bin/rails tailwindcss:build[verbose]` - emit the commands being run
264
271
  - `bin/rails tailwindcss:watch` - start live rebuilds, generating output on file changes
265
272
  - `bin/rails tailwindcss:watch[debug]` - generate unminimized output
266
- - `bin/rails tailwindcss:watch[poll]` - for systems without file system events
267
273
  - `bin/rails tailwindcss:watch[always]` - for systems without TTY (e.g., some docker containers)
274
+ - `bin/rails tailwindcss:watch[silent]` - suppress non-error output from tailwindcss (requires Tailwind CSS v4.3.1)
275
+ - `bin/rails tailwindcss:watch[verbose]` - emit the commands being run
268
276
 
269
- Note that you can combine task options, e.g. `rails tailwindcss:watch[debug,poll]`.
277
+ Note that you can combine task options, e.g. `rails tailwindcss:watch[debug,always]`.
270
278
 
271
279
  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
280
 
@@ -311,14 +319,6 @@ and then running `rails server` (or just `puma`) will run the Tailwind watch pro
311
319
 
312
320
  This is a flexible command, which can be run with a few different options.
313
321
 
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
322
  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
323
 
324
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`.
@@ -354,35 +354,12 @@ Than use `@plugin` annotation in `app/assets/tailwind/application.css`:
354
354
 
355
355
  ### Using with PostCSS
356
356
 
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
- ```
357
+ > [!NOTE]
358
+ > Starting with Tailwind v4, the upstream CLI tool no longer supports PostCSS, and the `--postcss` option has
359
+ been removed. If you want to leverage PostCSS with Tailwind 3, please reference the [tailwindcss-rails v3
360
+ README](https://github.com/rails/tailwindcss-rails/tree/v3-stable?tab=readme-ov-file#using-with-postcss).
384
361
 
385
- Then you can use yarn or npm to install the dependencies.
362
+ 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
363
 
387
364
  ### Custom inputs or outputs
388
365
 
@@ -428,6 +405,10 @@ There is a [known issue](https://github.com/tailwindlabs/tailwindcss/issues/1724
428
405
 
429
406
  Please try uninstalling `watchman` and try running the watch task again.
430
407
 
408
+ ### The `build` command (or `bin/rails assets:precompile`) is hanging inside a docker container
409
+
410
+ Without a `WORKDIR`, tailwind may search the entire filesystem for files with CSS class names. So, please make sure your Dockerfile uses a `WORKDIR`.
411
+
431
412
  ### Lost keystrokes or hanging when using terminal-based debugging tools (e.g. IRB, Pry, `ruby/debug`...etc.) with the Puma plugin
432
413
 
433
414
  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
@@ -3,7 +3,7 @@ require "tailwindcss/ruby"
3
3
  module Tailwindcss
4
4
  module Commands
5
5
  class << self
6
- def compile_command(debug: false, **kwargs)
6
+ def compile_command(debug: false, silent: false, **kwargs)
7
7
  debug = ENV["TAILWINDCSS_DEBUG"].present? if ENV.key?("TAILWINDCSS_DEBUG")
8
8
  rails_root = defined?(Rails) ? Rails.root : Pathname.new(Dir.pwd)
9
9
 
@@ -14,6 +14,7 @@ module Tailwindcss
14
14
  ]
15
15
 
16
16
  command << "--minify" unless (debug || rails_css_compressor?)
17
+ command << "--silent" if silent
17
18
 
18
19
  postcss_path = rails_root.join("postcss.config.js")
19
20
  command += ["--postcss", postcss_path.to_s] if File.exist?(postcss_path)
@@ -21,11 +22,10 @@ module Tailwindcss
21
22
  command
22
23
  end
23
24
 
24
- def watch_command(always: false, poll: false, **kwargs)
25
+ def watch_command(always: false, **kwargs)
25
26
  compile_command(**kwargs).tap do |command|
26
27
  command << "-w"
27
28
  command << "always" if always
28
- command << "-p" if poll
29
29
  end
30
30
  end
31
31
 
@@ -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.5.0"
3
3
  end
data/lib/tasks/build.rake CHANGED
@@ -2,9 +2,10 @@ namespace :tailwindcss do
2
2
  desc "Build your Tailwind CSS"
3
3
  task build: [:environment, :engines] do |_, args|
4
4
  debug = args.extras.include?("debug")
5
+ silent = args.extras.include?("silent")
5
6
  verbose = args.extras.include?("verbose")
6
7
 
7
- command = Tailwindcss::Commands.compile_command(debug: debug)
8
+ command = Tailwindcss::Commands.compile_command(debug: debug, silent: silent)
8
9
  env = Tailwindcss::Commands.command_env(verbose: verbose)
9
10
  puts "Running: #{Shellwords.join(command)}" if verbose
10
11
 
@@ -14,11 +15,11 @@ namespace :tailwindcss do
14
15
  desc "Watch and build your Tailwind CSS on file changes"
15
16
  task watch: [:environment, :engines] do |_, args|
16
17
  debug = args.extras.include?("debug")
17
- poll = args.extras.include?("poll")
18
18
  always = args.extras.include?("always")
19
+ silent = args.extras.include?("silent")
19
20
  verbose = args.extras.include?("verbose")
20
21
 
21
- command = Tailwindcss::Commands.watch_command(always: always, debug: debug, poll: poll)
22
+ command = Tailwindcss::Commands.watch_command(always: always, debug: debug, silent: silent)
22
23
  env = Tailwindcss::Commands.command_env(verbose: verbose)
23
24
  puts "Running: #{Shellwords.join(command)}" if verbose
24
25
 
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.5.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: 4.0.6
115
115
  specification_version: 4
116
116
  summary: Integrate Tailwind CSS with the asset pipeline in Rails.
117
117
  test_files: []