From e670d358212f73340c33b8e3c228394f7a4212e6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Mar 2025 14:44:50 +0000 Subject: [PATCH 01/54] build(deps): bump tailwindcss-ruby from 4.0.7 to 4.0.9 Bumps [tailwindcss-ruby](https://github.com/flavorjones/tailwindcss-ruby) from 4.0.7 to 4.0.9. - [Release notes](https://github.com/flavorjones/tailwindcss-ruby/releases) - [Changelog](https://github.com/flavorjones/tailwindcss-ruby/blob/v4.x/CHANGELOG.md) - [Commits](https://github.com/flavorjones/tailwindcss-ruby/compare/v4.0.7...v4.0.9) --- updated-dependencies: - dependency-name: tailwindcss-ruby dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 730f94fb..054f9e8e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -140,11 +140,11 @@ GEM io-console (~> 0.5) securerandom (0.4.1) stringio (3.1.3) - tailwindcss-ruby (4.0.7) - tailwindcss-ruby (4.0.7-aarch64-linux-gnu) - tailwindcss-ruby (4.0.7-arm64-darwin) - tailwindcss-ruby (4.0.7-x86_64-darwin) - tailwindcss-ruby (4.0.7-x86_64-linux-gnu) + tailwindcss-ruby (4.0.9) + tailwindcss-ruby (4.0.9-aarch64-linux-gnu) + tailwindcss-ruby (4.0.9-arm64-darwin) + tailwindcss-ruby (4.0.9-x86_64-darwin) + tailwindcss-ruby (4.0.9-x86_64-linux-gnu) thor (1.3.2) timeout (0.4.3) tzinfo (2.0.6) From 3fc4b2e26b52325c7bd3437eaf1d1c696fe73f94 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 5 Mar 2025 10:10:09 -0500 Subject: [PATCH 02/54] dep: bundle update --- Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 054f9e8e..34457850 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - tailwindcss-rails (4.1.0) + tailwindcss-rails (4.2.0) railties (>= 7.0.0) tailwindcss-ruby (~> 4.0) @@ -110,7 +110,7 @@ GEM date stringio racc (1.8.1) - rack (3.1.10) + rack (3.1.11) rack-session (2.1.0) base64 (>= 0.1.0) rack (>= 3.0.0) @@ -139,7 +139,7 @@ GEM reline (0.6.0) io-console (~> 0.5) securerandom (0.4.1) - stringio (3.1.3) + stringio (3.1.5) tailwindcss-ruby (4.0.9) tailwindcss-ruby (4.0.9-aarch64-linux-gnu) tailwindcss-ruby (4.0.9-arm64-darwin) @@ -149,7 +149,7 @@ GEM timeout (0.4.3) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - uri (1.0.2) + uri (1.0.3) useragent (0.16.11) zeitwerk (2.7.2) From 14830b75a25271111e61b5d75d71e504527f5f83 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Mar 2025 15:14:17 +0000 Subject: [PATCH 03/54] build(deps): bump tailwindcss-ruby from 4.0.9 to 4.0.12 Bumps [tailwindcss-ruby](https://github.com/flavorjones/tailwindcss-ruby) from 4.0.9 to 4.0.12. - [Release notes](https://github.com/flavorjones/tailwindcss-ruby/releases) - [Changelog](https://github.com/flavorjones/tailwindcss-ruby/blob/v4.x/CHANGELOG.md) - [Commits](https://github.com/flavorjones/tailwindcss-ruby/compare/v4.0.9...v4.0.12) --- updated-dependencies: - dependency-name: tailwindcss-ruby dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 34457850..1aa66c0f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -140,11 +140,11 @@ GEM io-console (~> 0.5) securerandom (0.4.1) stringio (3.1.5) - tailwindcss-ruby (4.0.9) - tailwindcss-ruby (4.0.9-aarch64-linux-gnu) - tailwindcss-ruby (4.0.9-arm64-darwin) - tailwindcss-ruby (4.0.9-x86_64-darwin) - tailwindcss-ruby (4.0.9-x86_64-linux-gnu) + tailwindcss-ruby (4.0.12) + tailwindcss-ruby (4.0.12-aarch64-linux-gnu) + tailwindcss-ruby (4.0.12-arm64-darwin) + tailwindcss-ruby (4.0.12-x86_64-darwin) + tailwindcss-ruby (4.0.12-x86_64-linux-gnu) thor (1.3.2) timeout (0.4.3) tzinfo (2.0.6) From 91a67e904d8b405305c5b59750e8ba0f3b9d39d5 Mon Sep 17 00:00:00 2001 From: Patricio Mac Adden Date: Mon, 17 Mar 2025 09:37:50 -0300 Subject: [PATCH 04/54] Fix hardcoded attribute in form --- lib/generators/tailwindcss/scaffold/templates/_form.html.erb.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/generators/tailwindcss/scaffold/templates/_form.html.erb.tt b/lib/generators/tailwindcss/scaffold/templates/_form.html.erb.tt index e50790ce..1821201c 100644 --- a/lib/generators/tailwindcss/scaffold/templates/_form.html.erb.tt +++ b/lib/generators/tailwindcss/scaffold/templates/_form.html.erb.tt @@ -23,7 +23,7 @@ <%%= form.password_field :password_confirmation, class: ["block shadow-sm rounded-md border px-3 py-2 mt-2 w-full", {"border-gray-400 focus:outline-blue-600": <%= model_resource_name %>.errors[:password_confirmation].none?, "border-red-400 focus:outline-red-600": <%= model_resource_name %>.errors[:password_confirmation].any?}] %> <% elsif attribute.attachments? -%> <%%= form.label :<%= attribute.column_name %> %> - <%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, multiple: true, class: ["block shadow-sm rounded-md border px-3 py-2 mt-2 w-full", {"border-gray-400 focus:outline-blue-600": <%= model_resource_name %>.errors[:password].none?, "border-red-400 focus:outline-red-600": <%= model_resource_name %>.errors[:password].any?}] %> + <%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, multiple: true, class: ["block shadow-sm rounded-md border px-3 py-2 mt-2 w-full", {"border-gray-400 focus:outline-blue-600": <%= model_resource_name %>.errors[:<%= attribute.column_name %>].none?, "border-red-400 focus:outline-red-600": <%= model_resource_name %>.errors[:<%= attribute.column_name %>].any?}] %> <% else -%> <%%= form.label :<%= attribute.column_name %> %> <% if attribute.field_type == :textarea || attribute.field_type == :text_area -%> From 5034ada51e6e31736571e46399d85c97106a0e41 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Mar 2025 15:19:05 +0000 Subject: [PATCH 05/54] build(deps): bump tailwindcss-ruby from 4.0.12 to 4.0.14 Bumps [tailwindcss-ruby](https://github.com/flavorjones/tailwindcss-ruby) from 4.0.12 to 4.0.14. - [Release notes](https://github.com/flavorjones/tailwindcss-ruby/releases) - [Changelog](https://github.com/flavorjones/tailwindcss-ruby/blob/v4.x/CHANGELOG.md) - [Commits](https://github.com/flavorjones/tailwindcss-ruby/compare/v4.0.12...v4.0.14) --- updated-dependencies: - dependency-name: tailwindcss-ruby dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1aa66c0f..7480d3ef 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -140,11 +140,11 @@ GEM io-console (~> 0.5) securerandom (0.4.1) stringio (3.1.5) - tailwindcss-ruby (4.0.12) - tailwindcss-ruby (4.0.12-aarch64-linux-gnu) - tailwindcss-ruby (4.0.12-arm64-darwin) - tailwindcss-ruby (4.0.12-x86_64-darwin) - tailwindcss-ruby (4.0.12-x86_64-linux-gnu) + tailwindcss-ruby (4.0.14) + tailwindcss-ruby (4.0.14-aarch64-linux-gnu) + tailwindcss-ruby (4.0.14-arm64-darwin) + tailwindcss-ruby (4.0.14-x86_64-darwin) + tailwindcss-ruby (4.0.14-x86_64-linux-gnu) thor (1.3.2) timeout (0.4.3) tzinfo (2.0.6) From b70e705e07740be700d7465a3ce684b5188b7748 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Mar 2025 15:19:14 +0000 Subject: [PATCH 06/54] build(deps): bump railties from 8.0.1 to 8.0.2 Bumps [railties](https://github.com/rails/rails) from 8.0.1 to 8.0.2. - [Release notes](https://github.com/rails/rails/releases) - [Changelog](https://github.com/rails/rails/blob/v8.0.2/railties/CHANGELOG.md) - [Commits](https://github.com/rails/rails/compare/v8.0.1...v8.0.2) --- updated-dependencies: - dependency-name: railties dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1aa66c0f..3c305111 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,16 +8,16 @@ PATH GEM remote: https://rubygems.org/ specs: - actionmailer (8.0.1) - actionpack (= 8.0.1) - actionview (= 8.0.1) - activejob (= 8.0.1) - activesupport (= 8.0.1) + actionmailer (8.0.2) + actionpack (= 8.0.2) + actionview (= 8.0.2) + activejob (= 8.0.2) + activesupport (= 8.0.2) mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (8.0.1) - actionview (= 8.0.1) - activesupport (= 8.0.1) + actionpack (8.0.2) + actionview (= 8.0.2) + activesupport (= 8.0.2) nokogiri (>= 1.8.5) rack (>= 2.2.4) rack-session (>= 1.0.1) @@ -25,16 +25,16 @@ GEM rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) useragent (~> 0.16) - actionview (8.0.1) - activesupport (= 8.0.1) + actionview (8.0.2) + activesupport (= 8.0.2) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (8.0.1) - activesupport (= 8.0.1) + activejob (8.0.2) + activesupport (= 8.0.2) globalid (>= 0.3.6) - activesupport (8.0.1) + activesupport (8.0.2) base64 benchmark (>= 0.3) bigdecimal @@ -80,7 +80,7 @@ GEM net-smtp mini_mime (1.1.5) mini_portile2 (2.8.8) - minitest (5.25.4) + minitest (5.25.5) net-imap (0.5.6) date net-protocol @@ -90,18 +90,18 @@ GEM timeout net-smtp (0.5.1) net-protocol - nokogiri (1.18.3) + nokogiri (1.18.4) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.18.3-aarch64-linux-gnu) + nokogiri (1.18.4-aarch64-linux-gnu) racc (~> 1.4) - nokogiri (1.18.3-arm-linux-gnu) + nokogiri (1.18.4-arm-linux-gnu) racc (~> 1.4) - nokogiri (1.18.3-arm64-darwin) + nokogiri (1.18.4-arm64-darwin) racc (~> 1.4) - nokogiri (1.18.3-x86_64-darwin) + nokogiri (1.18.4-x86_64-darwin) racc (~> 1.4) - nokogiri (1.18.3-x86_64-linux-gnu) + nokogiri (1.18.4-x86_64-linux-gnu) racc (~> 1.4) pp (0.6.2) prettyprint @@ -110,7 +110,7 @@ GEM date stringio racc (1.8.1) - rack (3.1.11) + rack (3.1.12) rack-session (2.1.0) base64 (>= 0.1.0) rack (>= 3.0.0) @@ -125,9 +125,9 @@ GEM rails-html-sanitizer (1.6.2) loofah (~> 2.21) nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) - railties (8.0.1) - actionpack (= 8.0.1) - activesupport (= 8.0.1) + railties (8.0.2) + actionpack (= 8.0.2) + activesupport (= 8.0.2) irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) From bd57aab639c8ee5202ef7bf5b0fd437f3b05f2f7 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 19 Mar 2025 14:56:10 -0400 Subject: [PATCH 07/54] doc: update CHANGELOG [skip ci] --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ad013b2..719bc894 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # `tailwindcss-rails` Changelog +## next / unreleased + +### Fixed + +* Fix styles for form errors in some scaffold fields. #513 @patriciomacadden + + ## v4.2.0 / 2025-03-02 ### Features From 84a0d6bf869ade33e450c4b070e5fa7b5d3d7e8a Mon Sep 17 00:00:00 2001 From: Patricio Mac Adden Date: Wed, 19 Mar 2025 11:09:43 -0300 Subject: [PATCH 08/54] add accept_confirm if turbo is available so system tests don't fail. fixes #519 --- .../scaffold/scaffold_generator.rb | 1 + .../test_unit/scaffold/scaffold_generator.rb | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 lib/generators/test_unit/scaffold/scaffold_generator.rb diff --git a/lib/generators/tailwindcss/scaffold/scaffold_generator.rb b/lib/generators/tailwindcss/scaffold/scaffold_generator.rb index 39c2da1f..8748210d 100644 --- a/lib/generators/tailwindcss/scaffold/scaffold_generator.rb +++ b/lib/generators/tailwindcss/scaffold/scaffold_generator.rb @@ -1,5 +1,6 @@ require "rails/generators/erb/scaffold/scaffold_generator" require "rails/generators/resource_helpers" +require File.expand_path("../../test_unit/scaffold/scaffold_generator.rb", __dir__) module Tailwindcss module Generators diff --git a/lib/generators/test_unit/scaffold/scaffold_generator.rb b/lib/generators/test_unit/scaffold/scaffold_generator.rb new file mode 100644 index 00000000..b97d74e4 --- /dev/null +++ b/lib/generators/test_unit/scaffold/scaffold_generator.rb @@ -0,0 +1,19 @@ +require "rails/generators/test_unit/scaffold/scaffold_generator" + +module TestUnit # :nodoc: + module Generators # :nodoc: + class ScaffoldGenerator < Base # :nodoc: + def fix_system_test + if turbo_defined? + gsub_file File.join("test/system", class_path, "#{file_name.pluralize}_test.rb"), "click_on \"Destroy this #{human_name.downcase}\", match: :first", "accept_confirm { click_on \"Destroy this #{human_name.downcase}\", match: :first }" + end + end + + private + + def turbo_defined? + defined?(Turbo) + end + end + end +end From 0653d82770e5c3b5196b882117447213bddd1a03 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 19 Mar 2025 15:05:49 -0400 Subject: [PATCH 09/54] Make the system test gsub less finicky --- lib/generators/test_unit/scaffold/scaffold_generator.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/generators/test_unit/scaffold/scaffold_generator.rb b/lib/generators/test_unit/scaffold/scaffold_generator.rb index b97d74e4..ff809b32 100644 --- a/lib/generators/test_unit/scaffold/scaffold_generator.rb +++ b/lib/generators/test_unit/scaffold/scaffold_generator.rb @@ -5,7 +5,9 @@ module Generators # :nodoc: class ScaffoldGenerator < Base # :nodoc: def fix_system_test if turbo_defined? - gsub_file File.join("test/system", class_path, "#{file_name.pluralize}_test.rb"), "click_on \"Destroy this #{human_name.downcase}\", match: :first", "accept_confirm { click_on \"Destroy this #{human_name.downcase}\", match: :first }" + gsub_file File.join("test/system", class_path, "#{file_name.pluralize}_test.rb"), + /(click_on.*Destroy this.*)$/, + "accept_confirm { \\1 }" end end From 37c98c3e95d08c2ddb7f0766222b0840869ef820 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 19 Mar 2025 15:12:46 -0400 Subject: [PATCH 10/54] Add a simple integration test for the scaffolded system test --- test/integration/user_install_test.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/integration/user_install_test.sh b/test/integration/user_install_test.sh index 6f4ca301..bfd7a87c 100755 --- a/test/integration/user_install_test.sh +++ b/test/integration/user_install_test.sh @@ -63,6 +63,9 @@ fi bin/rails generate scaffold post title:string body:text published:boolean grep -q "Show" app/views/posts/index.html.erb +# TEST: the "accept_confirm" system test change was applied cleanly +grep -q "accept_confirm { click_on \"Destroy this post\"" test/system/posts_test.rb + # TEST: contents of the css file bin/rails tailwindcss:build[verbose] grep -q "py-2" app/assets/builds/tailwind.css From d08ca11298678a4b5128683ab9a3df19d23136d8 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 19 Mar 2025 15:20:33 -0400 Subject: [PATCH 11/54] version bump to v4.2.1 --- CHANGELOG.md | 3 ++- lib/tailwindcss/version.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 719bc894..47d080f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,11 @@ # `tailwindcss-rails` Changelog -## next / unreleased +## v4.2.1 / 2025-03-19 ### Fixed * Fix styles for form errors in some scaffold fields. #513 @patriciomacadden +* Update scaffold system tests to handle the "Destroy" confirmation prompt when Turbo is enabled. Fixes #519. #520 @patriciomacadden @flavorjones ## v4.2.0 / 2025-03-02 diff --git a/lib/tailwindcss/version.rb b/lib/tailwindcss/version.rb index a172caa0..86e02ae2 100644 --- a/lib/tailwindcss/version.rb +++ b/lib/tailwindcss/version.rb @@ -1,3 +1,3 @@ module Tailwindcss - VERSION = "4.2.0" + VERSION = "4.2.1" end From 11e7c3d21739ce1188c080138375a4927d3fe5e6 Mon Sep 17 00:00:00 2001 From: Patricio Mac Adden Date: Fri, 28 Mar 2025 09:58:15 -0300 Subject: [PATCH 12/54] Simplify markup --- .../tailwindcss/scaffold/templates/index.html.erb.tt | 4 +--- .../tailwindcss/scaffold/templates/show.html.erb.tt | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt b/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt index 848c97fb..12a0db16 100644 --- a/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt +++ b/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt @@ -18,9 +18,7 @@
<%%= link_to "Show", <%= model_resource_name(singular_table_name) %>, class: "w-full sm:w-auto text-center rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> <%%= link_to "Edit", <%= edit_helper(singular_table_name, type: :path) %>, class: "w-full sm:w-auto text-center rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> -
- <%%= button_to "Destroy", <%= model_resource_name %>, method: :delete, class: "w-full sm:w-auto rounded-md px-3.5 py-2.5 text-white bg-red-600 hover:bg-red-500 font-medium cursor-pointer", data: { turbo_confirm: "Are you sure?" } %> -
+ <%%= button_to "Destroy", <%= model_resource_name %>, method: :delete, class: "w-full sm:w-auto rounded-md px-3.5 py-2.5 text-white bg-red-600 hover:bg-red-500 font-medium cursor-pointer", data: { turbo_confirm: "Are you sure?" } %>
<%% end %> diff --git a/lib/generators/tailwindcss/scaffold/templates/show.html.erb.tt b/lib/generators/tailwindcss/scaffold/templates/show.html.erb.tt index b6f153c2..2b6687d2 100644 --- a/lib/generators/tailwindcss/scaffold/templates/show.html.erb.tt +++ b/lib/generators/tailwindcss/scaffold/templates/show.html.erb.tt @@ -11,7 +11,5 @@ <%%= link_to "Edit this <%= human_name.downcase %>", <%= edit_helper(type: :path) %>, class: "w-full sm:w-auto text-center rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> <%%= link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper %>_path, class: "w-full sm:w-auto text-center mt-2 sm:mt-0 sm:ml-2 rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> -
- <%%= button_to "Destroy this <%= human_name.downcase %>", <%= model_resource_name(prefix: "@") %>, method: :delete, class: "w-full rounded-md px-3.5 py-2.5 text-white bg-red-600 hover:bg-red-500 font-medium cursor-pointer", data: { turbo_confirm: "Are you sure?" } %> -
+ <%%= button_to "Destroy this <%= human_name.downcase %>", <%= model_resource_name(prefix: "@") %>, method: :delete, form_class: "sm:inline-block mt-2 sm:mt-0 sm:ml-2", class: "w-full rounded-md px-3.5 py-2.5 text-white bg-red-600 hover:bg-red-500 font-medium cursor-pointer", data: { turbo_confirm: "Are you sure?" } %> From f099ee65f73fefc070a4fa126bfdeb8c6fdcea08 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Mar 2025 15:02:14 +0000 Subject: [PATCH 13/54] build(deps): bump tailwindcss-ruby from 4.0.14 to 4.0.17 Bumps [tailwindcss-ruby](https://github.com/flavorjones/tailwindcss-ruby) from 4.0.14 to 4.0.17. - [Release notes](https://github.com/flavorjones/tailwindcss-ruby/releases) - [Changelog](https://github.com/flavorjones/tailwindcss-ruby/blob/main/CHANGELOG.md) - [Commits](https://github.com/flavorjones/tailwindcss-ruby/compare/v4.0.14...v4.0.17) --- updated-dependencies: - dependency-name: tailwindcss-ruby dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 459f089e..59dfd05d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -140,11 +140,11 @@ GEM io-console (~> 0.5) securerandom (0.4.1) stringio (3.1.5) - tailwindcss-ruby (4.0.14) - tailwindcss-ruby (4.0.14-aarch64-linux-gnu) - tailwindcss-ruby (4.0.14-arm64-darwin) - tailwindcss-ruby (4.0.14-x86_64-darwin) - tailwindcss-ruby (4.0.14-x86_64-linux-gnu) + tailwindcss-ruby (4.0.17) + tailwindcss-ruby (4.0.17-aarch64-linux-gnu) + tailwindcss-ruby (4.0.17-arm64-darwin) + tailwindcss-ruby (4.0.17-x86_64-darwin) + tailwindcss-ruby (4.0.17-x86_64-linux-gnu) thor (1.3.2) timeout (0.4.3) tzinfo (2.0.6) From b0d41eb5bbcee6c072457f2f06a0720b628ea5ed Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sat, 5 Apr 2025 11:11:08 -0400 Subject: [PATCH 14/54] ci: use the latest @tailwindcss/upgrade package --- README.md | 2 +- lib/install/upgrade_tailwindcss.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f7afe7a8..c9982de6 100644 --- a/README.md +++ b/README.md @@ -145,7 +145,7 @@ $ bin/rails tailwindcss:upgrade remove app/assets/stylesheets/application.tailwind.css 10.9.0 Running the upstream Tailwind CSS upgrader - run npx @tailwindcss/upgrade@next --force --config /home/user/myapp/config/tailwind.config.js from "." + run npx @tailwindcss/upgrade --force --config /home/user/myapp/config/tailwind.config.js from "." ≈ tailwindcss v4.0.0 │ Searching for CSS files in the current directory and its subdirectories… │ ↳ Linked `./config/tailwind.config.js` to `./app/assets/tailwind/application.css` diff --git a/lib/install/upgrade_tailwindcss.rb b/lib/install/upgrade_tailwindcss.rb index 6266583a..004d9a82 100644 --- a/lib/install/upgrade_tailwindcss.rb +++ b/lib/install/upgrade_tailwindcss.rb @@ -46,7 +46,7 @@ if system("npx --version") say "Running the upstream Tailwind CSS upgrader" - command = Shellwords.join(["npx", "@tailwindcss/upgrade@next", "--force", "--config", TAILWIND_CONFIG_PATH.to_s]) + command = Shellwords.join(["npx", "@tailwindcss/upgrade", "--force", "--config", TAILWIND_CONFIG_PATH.to_s]) success = run(command, abort_on_failure: false) unless success say "The upgrade tool failed!", :red From fd2505954c9a077ae17cee3e55dadd0434272776 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sat, 5 Apr 2025 09:39:13 -0400 Subject: [PATCH 15/54] Improve the state of debugging when things go wrong - The "verbose" flag turns on additional debugging output from tailwindcss - Document the "watchman" problem - Document how to use the "verbose" flag when troubleshooting --- README.md | 35 ++++++++++++++++++++++++++++++++++- lib/tailwindcss/commands.rb | 6 ++++++ lib/tasks/build.rake | 16 ++++++++++++---- 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c9982de6..7188adff 100644 --- a/README.md +++ b/README.md @@ -403,30 +403,63 @@ If you need to use a custom input or output file, you can run `bundle exec tailw ## Troubleshooting -Some common problems experienced by users ... +When having trouble with `tailwindcss:build` or `tailwindcss:watch`, the first thing you should do is collect some diagnostic information by setting the "verbose" flag, which will emit: + +1. the command being run (so you can try running `tailwindcss` yourself without the gem's help) +2. additional debugging output from `tailwindcss` by setting the env var `DEBUG=1` + +Here's what that looks like: + +``` sh +$ bin/rails tailwindcss:build[verbose] + +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 +≈ tailwindcss v4.0.17 + +Done in 37ms + +[38.22ms] [@tailwindcss/cli] (initial build) +[11.90ms] ↳ Setup compiler +[ 6.52ms] ↳ Scan for candidates +[10.39ms] ↳ Build CSS +[ 1.69ms] ↳ Optimize CSS +[ 5.80ms] ↳ Write output +``` + +### The `watch` command is hanging + +There is a [known issue](https://github.com/tailwindlabs/tailwindcss/issues/17246#issuecomment-2753067488) running `tailwindcss -w` (that's the CLI in watch mode) when the utility `watchman` is also installed. + +Please try uninstalling `watchman` and try running the watch task again. + ### Lost keystrokes or hanging when using terminal-based debugging tools (e.g. IRB, Pry, `ruby/debug`...etc.) with the Puma plugin 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. + ### Running in a docker container exits prematurely 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. 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`. + ### Conflict with sassc-rails 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. + ### Class names must be spelled out 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). + ### `ERROR: Cannot find the tailwindcss executable` for supported platform See https://github.com/flavorjones/tailwindcss-ruby for help. + ### Using asset-pipeline assets 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. diff --git a/lib/tailwindcss/commands.rb b/lib/tailwindcss/commands.rb index bef42fd2..99ad30e0 100644 --- a/lib/tailwindcss/commands.rb +++ b/lib/tailwindcss/commands.rb @@ -29,6 +29,12 @@ def watch_command(always: false, poll: false, **kwargs) end end + def command_env(verbose:) + {}.tap do |env| + env["DEBUG"] = "1" if verbose + end + end + def rails_css_compressor? defined?(Rails) && Rails&.application&.config&.assets&.css_compressor.present? end diff --git a/lib/tasks/build.rake b/lib/tasks/build.rake index 3044ff05..603c8059 100644 --- a/lib/tasks/build.rake +++ b/lib/tasks/build.rake @@ -2,9 +2,13 @@ namespace :tailwindcss do desc "Build your Tailwind CSS" task build: :environment do |_, args| debug = args.extras.include?("debug") + verbose = args.extras.include?("verbose") + command = Tailwindcss::Commands.compile_command(debug: debug) - puts command.inspect if args.extras.include?("verbose") - system(*command, exception: true) + env = Tailwindcss::Commands.command_env(verbose: verbose) + puts "Running: #{Shellwords.join(command)}" if verbose + + system(env, *command, exception: true) end desc "Watch and build your Tailwind CSS on file changes" @@ -12,9 +16,13 @@ namespace :tailwindcss do debug = args.extras.include?("debug") poll = args.extras.include?("poll") always = args.extras.include?("always") + verbose = args.extras.include?("verbose") + command = Tailwindcss::Commands.watch_command(always: always, debug: debug, poll: poll) - puts command.inspect if args.extras.include?("verbose") - system(*command) + env = Tailwindcss::Commands.command_env(verbose: verbose) + puts "Running: #{Shellwords.join(command)}" if verbose + + system(env, *command) rescue Interrupt puts "Received interrupt, exiting tailwindcss:watch" if args.extras.include?("verbose") end From f722f192de0f4d66d137196fc34e3052e9a3ed6f Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sat, 5 Apr 2025 12:00:19 -0400 Subject: [PATCH 16/54] version bump to v4.2.2 --- CHANGELOG.md | 9 +++++++++ Gemfile.lock | 2 +- lib/tailwindcss/version.rb | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47d080f9..e0f90dac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # `tailwindcss-rails` Changelog +## v4.2.2 / 2025-04-05 + +### Improved + +* The "tailwindcss:upgrade" task now uses the latest version of the `@tailwindcss/upgrade` tool. #529 @flavorjones +* The "verbose" flag on Rails tasks now emits additional tailwind CLI debugging info (e.g., `bin/rails tailwindcss:build[verbose]`). #530 @flavorjones +* Simplified the scaffold templates, removing unnecessary `div` tags. @523 @patriciomacadden + + ## v4.2.1 / 2025-03-19 ### Fixed diff --git a/Gemfile.lock b/Gemfile.lock index 59dfd05d..08ddee5a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - tailwindcss-rails (4.2.0) + tailwindcss-rails (4.2.2) railties (>= 7.0.0) tailwindcss-ruby (~> 4.0) diff --git a/lib/tailwindcss/version.rb b/lib/tailwindcss/version.rb index 86e02ae2..8a0f50d8 100644 --- a/lib/tailwindcss/version.rb +++ b/lib/tailwindcss/version.rb @@ -1,3 +1,3 @@ module Tailwindcss - VERSION = "4.2.1" + VERSION = "4.2.2" end From fa9e2caafb7d1258aef576889568600a06e53299 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Apr 2025 15:30:10 +0000 Subject: [PATCH 17/54] build(deps): bump tailwindcss-ruby from 4.0.17 to 4.1.4 Bumps [tailwindcss-ruby](https://github.com/flavorjones/tailwindcss-ruby) from 4.0.17 to 4.1.4. - [Release notes](https://github.com/flavorjones/tailwindcss-ruby/releases) - [Changelog](https://github.com/flavorjones/tailwindcss-ruby/blob/main/CHANGELOG.md) - [Commits](https://github.com/flavorjones/tailwindcss-ruby/compare/v4.0.17...v4.1.4) --- updated-dependencies: - dependency-name: tailwindcss-ruby dependency-version: 4.1.4 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 08ddee5a..ec551873 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -140,11 +140,11 @@ GEM io-console (~> 0.5) securerandom (0.4.1) stringio (3.1.5) - tailwindcss-ruby (4.0.17) - tailwindcss-ruby (4.0.17-aarch64-linux-gnu) - tailwindcss-ruby (4.0.17-arm64-darwin) - tailwindcss-ruby (4.0.17-x86_64-darwin) - tailwindcss-ruby (4.0.17-x86_64-linux-gnu) + tailwindcss-ruby (4.1.4) + tailwindcss-ruby (4.1.4-aarch64-linux-gnu) + tailwindcss-ruby (4.1.4-arm64-darwin) + tailwindcss-ruby (4.1.4-x86_64-darwin) + tailwindcss-ruby (4.1.4-x86_64-linux-gnu) thor (1.3.2) timeout (0.4.3) tzinfo (2.0.6) From 9c7179008b9c2db11a7908036b06f63dceeeb6db Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Fri, 2 May 2025 16:21:52 -0400 Subject: [PATCH 18/54] Pin the npm upgrade task to @tailwindcss/upgrade@4.1.4 because the 4.1.5 upgrade tool introduced a dependency on tailwind that I can't figure out how to resolve. Gah, this entire experience has been entirely frustrating as a downstream maintainer, FML --- README.md | 4 ++-- lib/install/upgrade_tailwindcss.rb | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7188adff..158b1750 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ Then, run `bin/rails tailwindcss:upgrade`. Among other things, this will try to - If present, moves `app/assets/stylesheets/application.tailwind.css` to `app/assets/tailwind/application.css`. - Removes unnecessary `stylesheet_link_tag "tailwindcss"` tags from the application layout. - Removes references to the Inter font from the application layout. -- Runs the upstream upgrader (note: requires `npx` to run the one-time upgrade, but highly recommended). +- Runs v4.1.4 of the upstream upgrader (note: requires `npx` to run the one-time upgrade, but highly recommended). @@ -145,7 +145,7 @@ $ bin/rails tailwindcss:upgrade remove app/assets/stylesheets/application.tailwind.css 10.9.0 Running the upstream Tailwind CSS upgrader - run npx @tailwindcss/upgrade --force --config /home/user/myapp/config/tailwind.config.js from "." + run npx @tailwindcss/upgrade@4.1.4 --force --config /home/user/myapp/config/tailwind.config.js from "." ≈ tailwindcss v4.0.0 │ Searching for CSS files in the current directory and its subdirectories… │ ↳ Linked `./config/tailwind.config.js` to `./app/assets/tailwind/application.css` diff --git a/lib/install/upgrade_tailwindcss.rb b/lib/install/upgrade_tailwindcss.rb index 004d9a82..d6ecadab 100644 --- a/lib/install/upgrade_tailwindcss.rb +++ b/lib/install/upgrade_tailwindcss.rb @@ -45,8 +45,14 @@ end if system("npx --version") + # We're pinning to v4.1.4 because v4.1.5 of the upgrade tool introduces a dependency version check + # on tailwind and I haven't been able to figure out how to get that to work reliably and I am + # extremely frustrated with the whole thing. See #544 + # + # At some point we will probably need to unpin this at which point I am sincerely hoping that + # someone else will do it. say "Running the upstream Tailwind CSS upgrader" - command = Shellwords.join(["npx", "@tailwindcss/upgrade", "--force", "--config", TAILWIND_CONFIG_PATH.to_s]) + command = Shellwords.join(["npx", "@tailwindcss/upgrade@4.1.4", "--force", "--config", TAILWIND_CONFIG_PATH.to_s]) success = run(command, abort_on_failure: false) unless success say "The upgrade tool failed!", :red From 114fca5b4e235dd9cb14f54161f75032fd247681 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Fri, 2 May 2025 16:45:32 -0400 Subject: [PATCH 19/54] version bump to v4.2.3 --- CHANGELOG.md | 7 +++++++ lib/tailwindcss/version.rb | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0f90dac..d662d7a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # `tailwindcss-rails` Changelog +## v4.2.3 / 2025-05-02 + +### Improved + +* The "tailwindcss:upgrade" task now pins to v4.1.4 of the `@tailwindcss/upgrade` tool. #544 @flavorjones + + ## v4.2.2 / 2025-04-05 ### Improved diff --git a/lib/tailwindcss/version.rb b/lib/tailwindcss/version.rb index 8a0f50d8..7ab2db8d 100644 --- a/lib/tailwindcss/version.rb +++ b/lib/tailwindcss/version.rb @@ -1,3 +1,3 @@ module Tailwindcss - VERSION = "4.2.2" + VERSION = "4.2.3" end From 3f6d06d0981435c5cdd37951925e31fe70c6870e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 May 2025 15:12:32 +0000 Subject: [PATCH 20/54] build(deps): bump tailwindcss-ruby from 4.1.4 to 4.1.5 Bumps [tailwindcss-ruby](https://github.com/flavorjones/tailwindcss-ruby) from 4.1.4 to 4.1.5. - [Release notes](https://github.com/flavorjones/tailwindcss-ruby/releases) - [Changelog](https://github.com/flavorjones/tailwindcss-ruby/blob/main/CHANGELOG.md) - [Commits](https://github.com/flavorjones/tailwindcss-ruby/compare/v4.1.4...v4.1.5) --- updated-dependencies: - dependency-name: tailwindcss-ruby dependency-version: 4.1.5 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index ec551873..bb16d405 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -140,11 +140,11 @@ GEM io-console (~> 0.5) securerandom (0.4.1) stringio (3.1.5) - tailwindcss-ruby (4.1.4) - tailwindcss-ruby (4.1.4-aarch64-linux-gnu) - tailwindcss-ruby (4.1.4-arm64-darwin) - tailwindcss-ruby (4.1.4-x86_64-darwin) - tailwindcss-ruby (4.1.4-x86_64-linux-gnu) + tailwindcss-ruby (4.1.5) + tailwindcss-ruby (4.1.5-aarch64-linux-gnu) + tailwindcss-ruby (4.1.5-arm64-darwin) + tailwindcss-ruby (4.1.5-x86_64-darwin) + tailwindcss-ruby (4.1.5-x86_64-linux-gnu) thor (1.3.2) timeout (0.4.3) tzinfo (2.0.6) From 9d0a9f5e81aac890cbc6476f49515d9d45dc8abe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 May 2025 14:17:03 +0000 Subject: [PATCH 21/54] build(deps): bump tailwindcss-ruby from 4.1.5 to 4.1.6 Bumps [tailwindcss-ruby](https://github.com/flavorjones/tailwindcss-ruby) from 4.1.5 to 4.1.6. - [Release notes](https://github.com/flavorjones/tailwindcss-ruby/releases) - [Changelog](https://github.com/flavorjones/tailwindcss-ruby/blob/main/CHANGELOG.md) - [Commits](https://github.com/flavorjones/tailwindcss-ruby/compare/v4.1.5...v4.1.6) --- updated-dependencies: - dependency-name: tailwindcss-ruby dependency-version: 4.1.6 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index bb16d405..f84bada9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -140,11 +140,11 @@ GEM io-console (~> 0.5) securerandom (0.4.1) stringio (3.1.5) - tailwindcss-ruby (4.1.5) - tailwindcss-ruby (4.1.5-aarch64-linux-gnu) - tailwindcss-ruby (4.1.5-arm64-darwin) - tailwindcss-ruby (4.1.5-x86_64-darwin) - tailwindcss-ruby (4.1.5-x86_64-linux-gnu) + tailwindcss-ruby (4.1.6) + tailwindcss-ruby (4.1.6-aarch64-linux-gnu) + tailwindcss-ruby (4.1.6-arm64-darwin) + tailwindcss-ruby (4.1.6-x86_64-darwin) + tailwindcss-ruby (4.1.6-x86_64-linux-gnu) thor (1.3.2) timeout (0.4.3) tzinfo (2.0.6) From 401b00b61c78c7dd7dfe33142d9a6660b8f4546c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 May 2025 14:16:45 +0000 Subject: [PATCH 22/54] build(deps): bump tailwindcss-ruby from 4.1.6 to 4.1.7 Bumps [tailwindcss-ruby](https://github.com/flavorjones/tailwindcss-ruby) from 4.1.6 to 4.1.7. - [Release notes](https://github.com/flavorjones/tailwindcss-ruby/releases) - [Changelog](https://github.com/flavorjones/tailwindcss-ruby/blob/main/CHANGELOG.md) - [Commits](https://github.com/flavorjones/tailwindcss-ruby/compare/v4.1.6...v4.1.7) --- updated-dependencies: - dependency-name: tailwindcss-ruby dependency-version: 4.1.7 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index f84bada9..9b0500db 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -140,11 +140,11 @@ GEM io-console (~> 0.5) securerandom (0.4.1) stringio (3.1.5) - tailwindcss-ruby (4.1.6) - tailwindcss-ruby (4.1.6-aarch64-linux-gnu) - tailwindcss-ruby (4.1.6-arm64-darwin) - tailwindcss-ruby (4.1.6-x86_64-darwin) - tailwindcss-ruby (4.1.6-x86_64-linux-gnu) + tailwindcss-ruby (4.1.7) + tailwindcss-ruby (4.1.7-aarch64-linux-gnu) + tailwindcss-ruby (4.1.7-arm64-darwin) + tailwindcss-ruby (4.1.7-x86_64-darwin) + tailwindcss-ruby (4.1.7-x86_64-linux-gnu) thor (1.3.2) timeout (0.4.3) tzinfo (2.0.6) From a66db017913c3097f8a4197408894c76d15a33d6 Mon Sep 17 00:00:00 2001 From: Sergey Moiseev Date: Thu, 12 Jun 2025 17:22:30 +0300 Subject: [PATCH 23/54] Implement Engines Support (#554) * Implement Engines Support * Correction in README.md * Remove engine test * Rename to engine.css * Initial test cleanup * Tests cleanup * Remove non-needed dup * Correction * Correct docs * doc: update README to indicate engine support is experimental --------- Co-authored-by: Mike Dalessio --- Gemfile.lock | 2 +- README.md | 82 ++++++++++++------------- lib/tailwindcss-rails.rb | 1 + lib/tailwindcss/engine.rb | 4 ++ lib/tailwindcss/engines.rb | 23 +++++++ test/lib/tailwindcss/engines_test.rb | 89 ++++++++++++++++++++++++++++ 6 files changed, 155 insertions(+), 46 deletions(-) create mode 100644 lib/tailwindcss/engines.rb create mode 100644 test/lib/tailwindcss/engines_test.rb diff --git a/Gemfile.lock b/Gemfile.lock index 9b0500db..3a61813b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - tailwindcss-rails (4.2.2) + tailwindcss-rails (4.2.3) railties (>= 7.0.0) tailwindcss-ruby (~> 4.0) diff --git a/README.md b/README.md index 158b1750..274fae80 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,9 @@ * [Using Tailwind plugins](#using-tailwind-plugins) * [Using with PostCSS](#using-with-postcss) * [Custom inputs or outputs](#custom-inputs-or-outputs) + * [Rails Engines support (Experimental)](#rails-engines-support-experimental) - [Troubleshooting](#troubleshooting) + * [The `watch` command is hanging](#the-watch-command-is-hanging) * [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) * [Running in a docker container exits prematurely](#running-in-a-docker-container-exits-prematurely) * [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 This gem depends on the `tailwindcss-ruby` gem to install a working Tailwind CLI executable. - ### Choosing a specific version of `tailwindcss` 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, -``` ruby +```ruby gem "tailwindcss-rails" # pin to tailwindcss version 3.4.13 @@ -59,7 +60,6 @@ gem "tailwindcss-ruby", "3.4.13" You can also use a local (npm-based) installation if you prefer, please go to https://github.com/flavorjones/tailwindcss-ruby for more information. - ## Upgrading your application from Tailwind v3 to v4 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: - update some local project files to meet some Tailwind CSS v4 conventions, - attempt to run the [upstream v4 upgrade tool](https://tailwindcss.com/docs/upgrade-guide#using-the-upgrade-tool). - ### You don't _have_ to upgrade 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. If you don't want to upgrade, then pin your application to v3.3.1 of this gem: -``` ruby +```ruby # Gemfile gem "tailwindcss-rails", "~> 3.3.1" # which transitively pins tailwindcss-ruby to v3 ``` 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`: -``` ruby +```ruby # Gemfile gem "tailwindcss-rails", "~> 3.3" gem "tailwindcss-ruby", "~> 3.4" # only necessary with tailwindcss-rails <= 3.3.0 ``` - ### Upgrade steps > [!WARNING] @@ -100,8 +98,8 @@ gem "tailwindcss-ruby", "~> 3.4" # only necessary with tailwindcss-rails <= 3.3. First, update to `tailwindcss-rails` v4.0.0 or higher. This will also ensure you're transitively depending on `tailwindcss-ruby` v4. -```html -# Gemfile +```ruby +# Gemfile gem "tailwindcss-rails", "~> 4.0" # which transitively pins tailwindcss-ruby to v4 ``` @@ -114,7 +112,7 @@ gem "tailwindcss-rails", "~> 4.0" # which transitively pins tailwindcss-ruby to 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. -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. +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.
Here's a detailed list of what the upgrade task does. @@ -131,7 +129,7 @@ Then, run `bin/rails tailwindcss:upgrade`. Among other things, this will try to
Here's what that upgrade looks like on a vanilla Rails app. -``` sh +```sh $ bin/rails tailwindcss:upgrade apply /path/to/tailwindcss-rails/lib/install/upgrade_tailwindcss.rb Removing references to 'defaultTheme' from /home/user/myapp/config/tailwind.config.js @@ -166,12 +164,11 @@ $ bin/rails tailwindcss:upgrade Done in 56ms run bundle install --quiet ``` -
+
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). - ### Troubleshooting a v4 upgrade 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: We'll try to improve the upgrade process over time, but for now you may need to do some manual work to upgrade. - ### Updating CSS class names for v4 > [!NOTE] @@ -208,9 +204,9 @@ With some additional manual work the upstream upgrade tool will update your appl "@tailwindcss/aspect-ratio": "^0.4.2", "@tailwindcss/container-queries": "^0.1.1", "@tailwindcss/forms": "^0.5.10", - "@tailwindcss/typography": "^0.5.16" + "@tailwindcss/typography": "^0.5.16", // And so on... - } + }, } ``` @@ -280,12 +276,10 @@ This gem also generates a `Procfile.dev` file which will run both the rails serv The `tailwindcss:build` is automatically attached to `assets:precompile`, so before the asset pipeline digests the files, the Tailwind output will be generated. - ### Building for testing 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. - ### Building unminified assets 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 - or run `rails tailwindcss:watch` as a separate process, - or run `bin/dev` which uses [Foreman](https://github.com/ddollar/foreman) - #### Puma plugin 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" and then running `rails server` (or just `puma`) will run the Tailwind watch process in the background. - #### Run `rails tailwindcss:watch` 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, 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`. - #### Foreman 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. - ### Using Tailwind plugins If you want to use Tailwind plugins, they can be installed using `package.json`. Using Yarn: -``` sh +```sh [ ! -f package.json ] && yarn init yarn add daisyui # example ``` Using npm: -``` sh +```sh npm init npm add daisyui # example ``` Than use `@plugin` annotation in `app/assets/tailwind/application.css`: -``` css +```css @import "tailwindcss"; @plugin "daisyui"; ``` - ### Using with PostCSS 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: export default { plugins: { "@tailwindcss/postcss": {}, - } -} + }, +}; ``` ⚠ 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 { Then you can use yarn or npm to install the dependencies. - ### Custom inputs or outputs 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. +### Rails Engines support (Experimental) + +_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)._ + +If you have Rails Engines in your application that use Tailwind CSS and provide an `app/assets/tailwind//engine.css` file, entry point files will be created for each of them in `app/assets/builds/tailwind/.css` so they can be included in your host application's Tailwind CSS by adding `@import "../builds/tailwind/"` to your `app/assets/tailwind/application.css` file. + +> [!IMPORTANT] +> 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. ## Troubleshooting @@ -410,7 +406,7 @@ When having trouble with `tailwindcss:build` or `tailwindcss:watch`, the first t Here's what that looks like: -``` sh +```sh $ bin/rails tailwindcss:build[verbose] 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 Please try uninstalling `watchman` and try running the watch task again. - ### Lost keystrokes or hanging when using terminal-based debugging tools (e.g. IRB, Pry, `ruby/debug`...etc.) with the Puma plugin 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. - ### Running in a docker container exits prematurely 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. 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`. - ### Conflict with sassc-rails 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. - ### Class names must be spelled out 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). - ### `ERROR: Cannot find the tailwindcss executable` for supported platform See https://github.com/flavorjones/tailwindcss-ruby for help. - ### Using asset-pipeline assets 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]( ```js module.exports = { - theme: { - extend: { - backgroundImage: { - 'image': "url('image.svg')" - } - } - } -} + theme: { + extend: { + backgroundImage: { + image: "url('image.svg')", + }, + }, + }, +}; ``` The inline version also works: ```html -
Has the image as it's background
+
+ Has the image as it's background +
``` ## License diff --git a/lib/tailwindcss-rails.rb b/lib/tailwindcss-rails.rb index 2b86ff1c..bdfb592d 100644 --- a/lib/tailwindcss-rails.rb +++ b/lib/tailwindcss-rails.rb @@ -2,5 +2,6 @@ module Tailwindcss end require_relative "tailwindcss/version" +require_relative "tailwindcss/engines" require_relative "tailwindcss/engine" require_relative "tailwindcss/commands" diff --git a/lib/tailwindcss/engine.rb b/lib/tailwindcss/engine.rb index 7b88c5f1..001004f8 100644 --- a/lib/tailwindcss/engine.rb +++ b/lib/tailwindcss/engine.rb @@ -15,5 +15,9 @@ class Engine < ::Rails::Engine config.app_generators do |g| g.template_engine :tailwindcss end + + config.after_initialize do + Tailwindcss::Engines.bundle + end end end diff --git a/lib/tailwindcss/engines.rb b/lib/tailwindcss/engines.rb new file mode 100644 index 00000000..d1d6bf63 --- /dev/null +++ b/lib/tailwindcss/engines.rb @@ -0,0 +1,23 @@ +module Tailwindcss + module Engines + class << self + def bundle + FileUtils.mkdir_p(Rails.root.join("app/assets/builds/tailwind")) + Rails::Engine.subclasses.select do |engine| + engine.root.join("app/assets/tailwind/#{engine.engine_name}/engine.css").exist? + end.each do |engine| + file_path = Rails.root.join("app/assets/builds/tailwind/#{engine.engine_name}.css") + FileUtils.rm(file_path) if File.exist?(file_path) + template = <<~TEMPLATE + /* DO NOT MODIFY THIS FILE, it was auto-generated by tailwindcss-rails */ + + @import "#{engine.root.join("app/assets/tailwind/#{engine.engine_name}/engine.css")}"; + TEMPLATE + File.open(file_path, 'w') do |file| + file.puts template + end + end + end + end + end +end diff --git a/test/lib/tailwindcss/engines_test.rb b/test/lib/tailwindcss/engines_test.rb new file mode 100644 index 00000000..f4c1b0d2 --- /dev/null +++ b/test/lib/tailwindcss/engines_test.rb @@ -0,0 +1,89 @@ +require "test_helper" +require "minitest/mock" + +class Tailwindcss::EnginesTest < ActiveSupport::TestCase + def setup + super + @tmpdir_path = Pathname.new(TAILWINDCSS_TEST_APP_ROOT) + @builds_dir = @tmpdir_path.join("app/assets/builds/tailwind") + end + + test "bundle creates the builds directory" do + Rails.stub(:root, @tmpdir_path) do + Tailwindcss::Engines.bundle + assert Dir.exist?(@builds_dir), "Expected directory #{@builds_dir} to be created" + end + end + + test "bundle generates CSS files for engine's tailwind assets" do + Rails.stub(:root, @tmpdir_path) do + setup_mock_engine("mock_engine", @tmpdir_path) + + Tailwindcss::Engines.bundle + + css_file_path = @builds_dir.join("mock_engine.css") + assert File.exist?(css_file_path), "Expected file #{css_file_path} to be created" + + content = File.read(css_file_path) + assert_match(/DO NOT MODIFY THIS FILE/, content) + assert_match(/@import ".*\/app\/assets\/tailwind\/mock_engine\/engine.css"/, content) + end + end + + test "bundle removes existing files before generating new ones" do + Rails.stub(:root, @tmpdir_path) do + setup_mock_engine("mock_engine", @tmpdir_path) + + FileUtils.mkdir_p(@builds_dir) + css_file_path = @builds_dir.join("mock_engine.css") + File.write(css_file_path, "OLD CONTENT") + + Tailwindcss::Engines.bundle + + content = File.read(css_file_path) + assert_no_match(/OLD CONTENT/, content) + assert_match(/DO NOT MODIFY THIS FILE/, content) + end + end + + test "bundle only processes engines with tailwind assets" do + Rails.stub(:root, @tmpdir_path) do + setup_mock_engine("engine_with_assets", @tmpdir_path) + + Class.new(Rails::Engine) do + define_singleton_method(:engine_name) { "engine_without_assets" } + define_singleton_method(:root) { Pathname.new(Dir.mktmpdir) } + end + + Tailwindcss::Engines.bundle + + assert File.exist?(@builds_dir.join("engine_with_assets.css")), "Expected CSS file for engine with assets" + refute File.exist?(@builds_dir.join("engine_without_assets.css")), "Expected no CSS file for engine without assets" + end + end + + test "bundle handles multiple engines" do + Rails.stub(:root, @tmpdir_path) do + setup_mock_engine("engine1", @tmpdir_path) + setup_mock_engine("engine2", @tmpdir_path) + + Tailwindcss::Engines.bundle + + assert File.exist?(@builds_dir.join("engine1.css")), "Expected CSS file for engine1" + assert File.exist?(@builds_dir.join("engine2.css")), "Expected CSS file for engine2" + end + end + + private + + def setup_mock_engine(name, root_path) + tailwind_dir = root_path.join("app/assets/tailwind/#{name}") + FileUtils.mkdir_p(tailwind_dir) + File.write(tailwind_dir.join("engine.css"), "/* Test CSS */") + + Class.new(Rails::Engine) do + define_singleton_method(:engine_name) { name } + define_singleton_method(:root) { root_path } + end + end +end From ae58bb0a5e42c10b7937b4a3a933f242c686f83e Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Thu, 12 Jun 2025 10:25:38 -0400 Subject: [PATCH 24/54] version bump to v4.3.0.rc1 --- CHANGELOG.md | 7 +++++++ lib/tailwindcss/version.rb | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d662d7a9..2c11a6fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # `tailwindcss-rails` Changelog +## v4.3.0.rc1 + +### Improved + +* Experimental support for Rails engines. Feedback is welcome at #355. #554 @bopm + + ## v4.2.3 / 2025-05-02 ### Improved diff --git a/lib/tailwindcss/version.rb b/lib/tailwindcss/version.rb index 7ab2db8d..b4acf0d9 100644 --- a/lib/tailwindcss/version.rb +++ b/lib/tailwindcss/version.rb @@ -1,3 +1,3 @@ module Tailwindcss - VERSION = "4.2.3" + VERSION = "4.3.0.rc1" end From 7e0b4d669af33e9d0e830ef08fd22ea34159bca6 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Thu, 12 Jun 2025 10:36:42 -0400 Subject: [PATCH 25/54] dev: update Gemfile.lock with new version --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3a61813b..1defe8d7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - tailwindcss-rails (4.2.3) + tailwindcss-rails (4.3.0.rc1) railties (>= 7.0.0) tailwindcss-ruby (~> 4.0) From f26db33751df017a695f17ddaf7b14c85a7a953a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Jun 2025 14:37:53 +0000 Subject: [PATCH 26/54] build(deps): bump tailwindcss-ruby from 4.1.7 to 4.1.8 Bumps [tailwindcss-ruby](https://github.com/flavorjones/tailwindcss-ruby) from 4.1.7 to 4.1.8. - [Release notes](https://github.com/flavorjones/tailwindcss-ruby/releases) - [Changelog](https://github.com/flavorjones/tailwindcss-ruby/blob/main/CHANGELOG.md) - [Commits](https://github.com/flavorjones/tailwindcss-ruby/compare/v4.1.7...v4.1.8) --- updated-dependencies: - dependency-name: tailwindcss-ruby dependency-version: 4.1.8 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1defe8d7..22cbba38 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -140,11 +140,11 @@ GEM io-console (~> 0.5) securerandom (0.4.1) stringio (3.1.5) - tailwindcss-ruby (4.1.7) - tailwindcss-ruby (4.1.7-aarch64-linux-gnu) - tailwindcss-ruby (4.1.7-arm64-darwin) - tailwindcss-ruby (4.1.7-x86_64-darwin) - tailwindcss-ruby (4.1.7-x86_64-linux-gnu) + tailwindcss-ruby (4.1.8) + tailwindcss-ruby (4.1.8-aarch64-linux-gnu) + tailwindcss-ruby (4.1.8-arm64-darwin) + tailwindcss-ruby (4.1.8-x86_64-darwin) + tailwindcss-ruby (4.1.8-x86_64-linux-gnu) thor (1.3.2) timeout (0.4.3) tzinfo (2.0.6) From 7c668844dbbc0fa594cb519070c64ff41119d76b Mon Sep 17 00:00:00 2001 From: Sergey Moiseev Date: Mon, 16 Jun 2025 05:05:30 +0300 Subject: [PATCH 27/54] Fix read-only file system issue (#556) * Fix read-only file system issue * Changes due to review * Restore original formatting * Changes due to review * Remove new line * Clarify "engines" rake task description --------- Co-authored-by: Mike Dalessio --- README.md | 2 +- lib/tailwindcss/engine.rb | 4 ---- lib/tasks/build.rake | 9 +++++++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 274fae80..450a177d 100644 --- a/README.md +++ b/README.md @@ -392,7 +392,7 @@ If you need to use a custom input or output file, you can run `bundle exec tailw _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)._ -If you have Rails Engines in your application that use Tailwind CSS and provide an `app/assets/tailwind//engine.css` file, entry point files will be created for each of them in `app/assets/builds/tailwind/.css` so they can be included in your host application's Tailwind CSS by adding `@import "../builds/tailwind/"` to your `app/assets/tailwind/application.css` file. +If you have Rails Engines in your application that use Tailwind CSS and provide an `app/assets/tailwind//engine.css` file, entry point files will be created for each of them in `app/assets/builds/tailwind/.css` on the first build/watch invocation or manual call for `rails tailwindcss:engines` so they can be included in your host application's Tailwind CSS by adding `@import "../builds/tailwind/"` to your `app/assets/tailwind/application.css` file. > [!IMPORTANT] > 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. diff --git a/lib/tailwindcss/engine.rb b/lib/tailwindcss/engine.rb index 001004f8..7b88c5f1 100644 --- a/lib/tailwindcss/engine.rb +++ b/lib/tailwindcss/engine.rb @@ -15,9 +15,5 @@ class Engine < ::Rails::Engine config.app_generators do |g| g.template_engine :tailwindcss end - - config.after_initialize do - Tailwindcss::Engines.bundle - end end end diff --git a/lib/tasks/build.rake b/lib/tasks/build.rake index 603c8059..d176f2cd 100644 --- a/lib/tasks/build.rake +++ b/lib/tasks/build.rake @@ -1,6 +1,6 @@ namespace :tailwindcss do desc "Build your Tailwind CSS" - task build: :environment do |_, args| + task build: [:environment, :engines] do |_, args| debug = args.extras.include?("debug") verbose = args.extras.include?("verbose") @@ -12,7 +12,7 @@ namespace :tailwindcss do end desc "Watch and build your Tailwind CSS on file changes" - task watch: :environment do |_, args| + task watch: [:environment, :engines] do |_, args| debug = args.extras.include?("debug") poll = args.extras.include?("poll") always = args.extras.include?("always") @@ -26,6 +26,11 @@ namespace :tailwindcss do rescue Interrupt puts "Received interrupt, exiting tailwindcss:watch" if args.extras.include?("verbose") end + + desc "Create Tailwind CSS entry point files for Rails Engines" + task engines: :environment do + Tailwindcss::Engines.bundle + end end Rake::Task["assets:precompile"].enhance(["tailwindcss:build"]) From c05cbdcf5094c8ae37fb7357b3292aabc5b2cfdf Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sun, 15 Jun 2025 22:01:52 -0400 Subject: [PATCH 28/54] version bump to v4.3.0.rc2 --- CHANGELOG.md | 4 ++-- lib/tailwindcss/version.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c11a6fd..95fd82af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,10 @@ # `tailwindcss-rails` Changelog -## v4.3.0.rc1 +## v4.3.0.rc2 ### Improved -* Experimental support for Rails engines. Feedback is welcome at #355. #554 @bopm +* Experimental support for Rails engines. Feedback is welcome at #355. #554, #556 @bopm ## v4.2.3 / 2025-05-02 diff --git a/lib/tailwindcss/version.rb b/lib/tailwindcss/version.rb index b4acf0d9..d1d65d16 100644 --- a/lib/tailwindcss/version.rb +++ b/lib/tailwindcss/version.rb @@ -1,3 +1,3 @@ module Tailwindcss - VERSION = "4.3.0.rc1" + VERSION = "4.3.0.rc2" end From 71b5fe500c5bdfd73766cdb1ea4ce506b5213e22 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Jun 2025 16:00:29 +0000 Subject: [PATCH 29/54] build(deps): bump tailwindcss-ruby from 4.1.8 to 4.1.10 Bumps [tailwindcss-ruby](https://github.com/flavorjones/tailwindcss-ruby) from 4.1.8 to 4.1.10. - [Release notes](https://github.com/flavorjones/tailwindcss-ruby/releases) - [Changelog](https://github.com/flavorjones/tailwindcss-ruby/blob/main/CHANGELOG.md) - [Commits](https://github.com/flavorjones/tailwindcss-ruby/compare/v4.1.8...v4.1.10) --- updated-dependencies: - dependency-name: tailwindcss-ruby dependency-version: 4.1.10 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 22cbba38..dc9444f1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -140,11 +140,11 @@ GEM io-console (~> 0.5) securerandom (0.4.1) stringio (3.1.5) - tailwindcss-ruby (4.1.8) - tailwindcss-ruby (4.1.8-aarch64-linux-gnu) - tailwindcss-ruby (4.1.8-arm64-darwin) - tailwindcss-ruby (4.1.8-x86_64-darwin) - tailwindcss-ruby (4.1.8-x86_64-linux-gnu) + tailwindcss-ruby (4.1.10) + tailwindcss-ruby (4.1.10-aarch64-linux-gnu) + tailwindcss-ruby (4.1.10-arm64-darwin) + tailwindcss-ruby (4.1.10-x86_64-darwin) + tailwindcss-ruby (4.1.10-x86_64-linux-gnu) thor (1.3.2) timeout (0.4.3) tzinfo (2.0.6) From 7da93baddaaf55eae17010f30469e5fba8aa7ee1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Jun 2025 15:59:22 +0000 Subject: [PATCH 30/54] build(deps): bump debug from 1.10.0 to 1.11.0 Bumps [debug](https://github.com/ruby/debug) from 1.10.0 to 1.11.0. - [Release notes](https://github.com/ruby/debug/releases) - [Commits](https://github.com/ruby/debug/compare/v1.10.0...v1.11.0) --- updated-dependencies: - dependency-name: debug dependency-version: 1.11.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index dc9444f1..ff8de6e0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -55,17 +55,18 @@ GEM connection_pool (2.5.0) crass (1.0.6) date (3.4.1) - debug (1.10.0) + debug (1.11.0) irb (~> 1.10) reline (>= 0.3.8) drb (2.2.1) + erb (5.0.1) erubi (1.13.1) globalid (1.2.1) activesupport (>= 6.1) i18n (1.14.7) concurrent-ruby (~> 1.0) io-console (0.8.0) - irb (1.15.1) + irb (1.15.2) pp (>= 0.6.0) rdoc (>= 4.0.0) reline (>= 0.4.2) @@ -106,7 +107,7 @@ GEM pp (0.6.2) prettyprint prettyprint (0.2.0) - psych (5.2.3) + psych (5.2.6) date stringio racc (1.8.1) @@ -134,12 +135,13 @@ GEM thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) rake (13.2.1) - rdoc (6.12.0) + rdoc (6.14.1) + erb psych (>= 4.0.0) - reline (0.6.0) + reline (0.6.1) io-console (~> 0.5) securerandom (0.4.1) - stringio (3.1.5) + stringio (3.1.7) tailwindcss-ruby (4.1.10) tailwindcss-ruby (4.1.10-aarch64-linux-gnu) tailwindcss-ruby (4.1.10-arm64-darwin) From b6cb944e46bb7d042273bc4a3fed40cf28ab1288 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sat, 5 Jul 2025 17:17:10 -0400 Subject: [PATCH 31/54] Gracefully handle --skip-system-test Fixes #559 --- .../test_unit/scaffold/scaffold_generator.rb | 2 +- test/integration/user_install_test.sh | 58 +++++++++++++------ 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/lib/generators/test_unit/scaffold/scaffold_generator.rb b/lib/generators/test_unit/scaffold/scaffold_generator.rb index ff809b32..c9f16476 100644 --- a/lib/generators/test_unit/scaffold/scaffold_generator.rb +++ b/lib/generators/test_unit/scaffold/scaffold_generator.rb @@ -4,7 +4,7 @@ module TestUnit # :nodoc: module Generators # :nodoc: class ScaffoldGenerator < Base # :nodoc: def fix_system_test - if turbo_defined? + if turbo_defined? && options[:system_tests] gsub_file File.join("test/system", class_path, "#{file_name.pluralize}_test.rb"), /(click_on.*Destroy this.*)$/, "accept_confirm { \\1 }" diff --git a/test/integration/user_install_test.sh b/test/integration/user_install_test.sh index bfd7a87c..7bd3b630 100755 --- a/test/integration/user_install_test.sh +++ b/test/integration/user_install_test.sh @@ -11,34 +11,41 @@ bundle remove actionmailer || true bundle remove rails || true bundle add rails --skip-install ${RAILSOPTS:-} bundle install --prefer-local +bundle exec rails -v # do our work a directory with spaces in the name (#176, #184) rm -rf "My Workspace" mkdir "My Workspace" pushd "My Workspace" -# create a rails app -bundle exec rails -v +function prepare_deps { + # make sure to use the same version of rails (e.g., install from git source if necessary) + bundle remove rails --skip-install + bundle add rails --skip-install ${RAILSOPTS:-} + + # use the tailwindcss-rails under test + bundle add tailwindcss-rails --skip-install --path="../.." + bundle add tailwindcss-ruby --skip-install ${TAILWINDCSSOPTS:-} + bundle install --prefer-local + bundle show --paths | fgrep tailwind + bundle binstubs --all +} + +function install_tailwindcss { + # install tailwindcss + bin/rails tailwindcss:install + + # TEST: tailwind was installed correctly + grep -q "
> Rakefile @@ -73,4 +80,17 @@ grep -q "py-2" app/assets/builds/tailwind.css # TEST: contents include application.css directives grep -q "#abc12399" app/assets/builds/tailwind.css +# Application variation #2 ---------------------------------------- +popd +bundle exec rails new test-install2 --skip-bundle --skip-system-test +pushd test-install2 + +prepare_deps +install_tailwindcss + +# TEST: presence of the generated file +# TEST: nothing blew up without system tests, https://github.com/rails/tailwindcss-rails/issues/559 +bin/rails generate scaffold post title:string body:text published:boolean +grep -q "Show" app/views/posts/index.html.erb + echo "OK" From 6e1e24a7216971882104a715155fd5e5633a7207 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sun, 6 Jul 2025 14:56:57 -0400 Subject: [PATCH 32/54] dep: bundle update --- Gemfile.lock | 56 ++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index ff8de6e0..0a9eb668 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - tailwindcss-rails (4.3.0.rc1) + tailwindcss-rails (4.3.0.rc2) railties (>= 7.0.0) tailwindcss-ruby (~> 4.0) @@ -47,18 +47,18 @@ GEM securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) uri (>= 0.13.1) - base64 (0.2.0) - benchmark (0.4.0) - bigdecimal (3.1.9) + base64 (0.3.0) + benchmark (0.4.1) + bigdecimal (3.2.2) builder (3.3.0) concurrent-ruby (1.3.5) - connection_pool (2.5.0) + connection_pool (2.5.3) crass (1.0.6) date (3.4.1) debug (1.11.0) irb (~> 1.10) reline (>= 0.3.8) - drb (2.2.1) + drb (2.2.3) erb (5.0.1) erubi (1.13.1) globalid (1.2.1) @@ -70,8 +70,8 @@ GEM pp (>= 0.6.0) rdoc (>= 4.0.0) reline (>= 0.4.2) - logger (1.6.6) - loofah (2.24.0) + logger (1.7.0) + loofah (2.24.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -80,9 +80,9 @@ GEM net-pop net-smtp mini_mime (1.1.5) - mini_portile2 (2.8.8) + mini_portile2 (2.8.9) minitest (5.25.5) - net-imap (0.5.6) + net-imap (0.5.9) date net-protocol net-pop (0.1.2) @@ -91,18 +91,18 @@ GEM timeout net-smtp (0.5.1) net-protocol - nokogiri (1.18.4) + nokogiri (1.18.8) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.18.4-aarch64-linux-gnu) + nokogiri (1.18.8-aarch64-linux-gnu) racc (~> 1.4) - nokogiri (1.18.4-arm-linux-gnu) + nokogiri (1.18.8-arm-linux-gnu) racc (~> 1.4) - nokogiri (1.18.4-arm64-darwin) + nokogiri (1.18.8-arm64-darwin) racc (~> 1.4) - nokogiri (1.18.4-x86_64-darwin) + nokogiri (1.18.8-x86_64-darwin) racc (~> 1.4) - nokogiri (1.18.4-x86_64-linux-gnu) + nokogiri (1.18.8-x86_64-linux-gnu) racc (~> 1.4) pp (0.6.2) prettyprint @@ -111,15 +111,15 @@ GEM date stringio racc (1.8.1) - rack (3.1.12) - rack-session (2.1.0) + rack (3.1.16) + rack-session (2.1.1) base64 (>= 0.1.0) rack (>= 3.0.0) rack-test (2.2.0) rack (>= 1.3) rackup (2.2.1) rack (>= 3) - rails-dom-testing (2.2.0) + rails-dom-testing (2.3.0) activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) @@ -134,26 +134,26 @@ GEM rake (>= 12.2) thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) - rake (13.2.1) - rdoc (6.14.1) + rake (13.3.0) + rdoc (6.14.2) erb psych (>= 4.0.0) reline (0.6.1) io-console (~> 0.5) securerandom (0.4.1) stringio (3.1.7) - tailwindcss-ruby (4.1.10) - tailwindcss-ruby (4.1.10-aarch64-linux-gnu) - tailwindcss-ruby (4.1.10-arm64-darwin) - tailwindcss-ruby (4.1.10-x86_64-darwin) - tailwindcss-ruby (4.1.10-x86_64-linux-gnu) + tailwindcss-ruby (4.1.11) + tailwindcss-ruby (4.1.11-aarch64-linux-gnu) + tailwindcss-ruby (4.1.11-arm64-darwin) + tailwindcss-ruby (4.1.11-x86_64-darwin) + tailwindcss-ruby (4.1.11-x86_64-linux-gnu) thor (1.3.2) timeout (0.4.3) tzinfo (2.0.6) concurrent-ruby (~> 1.0) uri (1.0.3) useragent (0.16.11) - zeitwerk (2.7.2) + zeitwerk (2.7.3) PLATFORMS aarch64-linux @@ -169,4 +169,4 @@ DEPENDENCIES tailwindcss-rails! BUNDLED WITH - 2.5.23 + 2.6.7 From 098e02b1d3664e8b18ae8b80f980360c10b0511a Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sun, 6 Jul 2025 15:04:30 -0400 Subject: [PATCH 33/54] version bump to v4.3.0 --- CHANGELOG.md | 3 ++- Gemfile.lock | 2 +- lib/tailwindcss/version.rb | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95fd82af..e78bab71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,11 @@ # `tailwindcss-rails` Changelog -## v4.3.0.rc2 +## v4.3.0 ### Improved * Experimental support for Rails engines. Feedback is welcome at #355. #554, #556 @bopm +* Gracefully handle application created with `--skip-system-test`. #559, #562 @flavorjones ## v4.2.3 / 2025-05-02 diff --git a/Gemfile.lock b/Gemfile.lock index 0a9eb668..5dd291ac 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - tailwindcss-rails (4.3.0.rc2) + tailwindcss-rails (4.3.0) railties (>= 7.0.0) tailwindcss-ruby (~> 4.0) diff --git a/lib/tailwindcss/version.rb b/lib/tailwindcss/version.rb index d1d65d16..5629f4a4 100644 --- a/lib/tailwindcss/version.rb +++ b/lib/tailwindcss/version.rb @@ -1,3 +1,3 @@ module Tailwindcss - VERSION = "4.3.0.rc2" + VERSION = "4.3.0" end From 4a2f954d90aa51df219202ad76144388d9978fec Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sun, 6 Jul 2025 15:07:19 -0400 Subject: [PATCH 34/54] doc: fix date in changelog [skip ci] --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e78bab71..aae4aa48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # `tailwindcss-rails` Changelog -## v4.3.0 +## v4.3.0 / 2025-07-06 ### Improved From eb7423d9b4e2bf609999f987d11b24e057b2a31d Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 20 Aug 2025 18:01:11 -0400 Subject: [PATCH 35/54] ci: Fix integration tests with rails 7.2 which was failing because it was trying to fit Rails 7.2 into the Gemfile.lock dependencies set by rails 8. --- test/integration/user_install_test.sh | 2 ++ test/integration/user_upgrade_test.sh | 2 ++ 2 files changed, 4 insertions(+) diff --git a/test/integration/user_install_test.sh b/test/integration/user_install_test.sh index 7bd3b630..30d46095 100755 --- a/test/integration/user_install_test.sh +++ b/test/integration/user_install_test.sh @@ -9,6 +9,7 @@ set -eux rm -f Gemfile.lock bundle remove actionmailer || true bundle remove rails || true +rm -f Gemfile.lock bundle add rails --skip-install ${RAILSOPTS:-} bundle install --prefer-local bundle exec rails -v @@ -21,6 +22,7 @@ pushd "My Workspace" function prepare_deps { # make sure to use the same version of rails (e.g., install from git source if necessary) bundle remove rails --skip-install + rm -f Gemfile.lock bundle add rails --skip-install ${RAILSOPTS:-} # use the tailwindcss-rails under test diff --git a/test/integration/user_upgrade_test.sh b/test/integration/user_upgrade_test.sh index d6017efc..e30a8665 100755 --- a/test/integration/user_upgrade_test.sh +++ b/test/integration/user_upgrade_test.sh @@ -9,6 +9,7 @@ set -eux rm -f Gemfile.lock bundle remove actionmailer || true bundle remove rails || true +rm -f Gemfile.lock bundle add rails --skip-install ${RAILSOPTS:-} bundle install --prefer-local @@ -24,6 +25,7 @@ pushd test-upgrade # make sure to use the same version of rails (e.g., install from git source if necessary) bundle remove rails --skip-install +rm -f Gemfile.lock bundle add rails --skip-install ${RAILSOPTS:-} # set up app with tailwindcss-rails v3 and tailwindcss-ruby v3 From c08e36de88b83189686b1d208574e0909b74cfaf Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 20 Aug 2025 18:03:31 -0400 Subject: [PATCH 36/54] ci: fix integration tests with rails 8.0 which was failing because the bundler binstub has been removed in modern bundler, see https://github.com/rubygems/rubygems/pull/8345 --- test/integration/user_install_test.sh | 1 + test/integration/user_upgrade_test.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/test/integration/user_install_test.sh b/test/integration/user_install_test.sh index 30d46095..c68123ea 100755 --- a/test/integration/user_install_test.sh +++ b/test/integration/user_install_test.sh @@ -6,6 +6,7 @@ set -o pipefail set -eux # set up dependencies +gem install bcrypt # it's complicated, see Rails 7549ba77. can probably be removed once Rails 8.0 is EOL. rm -f Gemfile.lock bundle remove actionmailer || true bundle remove rails || true diff --git a/test/integration/user_upgrade_test.sh b/test/integration/user_upgrade_test.sh index e30a8665..ae4c6852 100755 --- a/test/integration/user_upgrade_test.sh +++ b/test/integration/user_upgrade_test.sh @@ -6,6 +6,7 @@ set -o pipefail set -eux # set up dependencies +gem install bcrypt # it's complicated, see Rails 7549ba77. can probably be removed once Rails 8.0 is EOL. rm -f Gemfile.lock bundle remove actionmailer || true bundle remove rails || true From 611dae06208c1710c0797ef351b276ff070dffe8 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 20 Aug 2025 18:19:55 -0400 Subject: [PATCH 37/54] ci: drop windows integration tests the sqlite failures have nothing to do with this gem, and it's just noise right now ref: https://github.com/sparklemotion/sqlite3-ruby/issues/628 --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3822e414..afec5642 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,7 @@ jobs: strategy: fail-fast: false matrix: - plat: ["ubuntu", "windows", "macos"] + plat: [ "ubuntu", "macos" ] runs-on: ${{matrix.plat}}-latest steps: - uses: actions/checkout@v4 @@ -51,7 +51,7 @@ jobs: strategy: fail-fast: false matrix: - plat: ["ubuntu", "macos"] # TODO: on windows the tailwind upgrader tests are failing + plat: [ "ubuntu", "macos" ] runs-on: ${{matrix.plat}}-latest steps: - uses: actions/checkout@v4 From d0a8e098a6d5e2c74510520b4840ff14cd0b4d61 Mon Sep 17 00:00:00 2001 From: Yasuo Honda Date: Wed, 20 Aug 2025 15:14:10 +0900 Subject: [PATCH 38/54] Address `warning: mismatched indentations at 'end' with 'class' at 3` This commit addresses the `warning: mismatched indentations at 'end' with 'class' at 3` ```ruby $ bundle exec rake test /home/yahonda/src/github.com/rails/tailwindcss-rails/lib/tailwindcss/engines.rb:21: warning: mismatched indentations at 'end' with 'class' at 3 Run options: --seed 14561 ........................ Finished in 0.031471s, 762.6091 runs/s, 6164.4235 assertions/s. 24 runs, 194 assertions, 0 failures, 0 errors, 0 skips ``` --- lib/tailwindcss/engines.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tailwindcss/engines.rb b/lib/tailwindcss/engines.rb index d1d6bf63..90bd6d59 100644 --- a/lib/tailwindcss/engines.rb +++ b/lib/tailwindcss/engines.rb @@ -1,6 +1,6 @@ module Tailwindcss module Engines - class << self + class << self def bundle FileUtils.mkdir_p(Rails.root.join("app/assets/builds/tailwind")) Rails::Engine.subclasses.select do |engine| From 2bf681e43790a2dcb82badc7c83cbda3a2011124 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Aug 2025 22:27:37 +0000 Subject: [PATCH 39/54] build(deps): bump actions/checkout from 4 to 5 Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 6 +++--- .github/workflows/upstream.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index afec5642..eb253890 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: matrix: ruby: ["3.1", "3.2", "3.3", "3.4", "head"] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - run: rm Gemfile.lock - uses: ruby/setup-ruby@v1 with: @@ -39,7 +39,7 @@ jobs: plat: [ "ubuntu", "macos" ] runs-on: ${{matrix.plat}}-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: ruby/setup-ruby@v1 with: ruby-version: "3.4" @@ -54,7 +54,7 @@ jobs: plat: [ "ubuntu", "macos" ] runs-on: ${{matrix.plat}}-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: ruby/setup-ruby@v1 with: ruby-version: "3.4" diff --git a/.github/workflows/upstream.yml b/.github/workflows/upstream.yml index e1b12dea..5e2440ab 100644 --- a/.github/workflows/upstream.yml +++ b/.github/workflows/upstream.yml @@ -20,7 +20,7 @@ jobs: matrix: ruby: ["3.3"] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{matrix.ruby}} @@ -45,7 +45,7 @@ jobs: env: RAILSOPTS: --git=https://github.com/rails/rails --ref=${{ matrix.ref }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: ruby/setup-ruby@v1 with: ruby-version: "3.3" @@ -64,7 +64,7 @@ jobs: env: RAILSOPTS: --git=https://github.com/rails/rails --ref=${{ matrix.ref }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: ruby/setup-ruby@v1 with: ruby-version: "3.3" From 1a87630d54a2adc8053284f962db4070b1f0cc18 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Mon, 27 Oct 2025 15:19:52 -0400 Subject: [PATCH 40/54] Add Rails 8.1 to the CI testing matrix --- .github/workflows/upstream.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upstream.yml b/.github/workflows/upstream.yml index 5e2440ab..8d561995 100644 --- a/.github/workflows/upstream.yml +++ b/.github/workflows/upstream.yml @@ -41,7 +41,7 @@ jobs: fail-fast: false matrix: plat: ["ubuntu"] - ref: ["7-2-stable", "8-0-stable", "main"] + ref: ["7-2-stable", "8-0-stable", "8-1-stable", "main"] env: RAILSOPTS: --git=https://github.com/rails/rails --ref=${{ matrix.ref }} steps: From 770b8e90668f7a3b14aebeae8fb38188bd050d15 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Mon, 27 Oct 2025 15:40:50 -0400 Subject: [PATCH 41/54] Gracefully handle the new Rails default of "no system tests" Fixes #585 --- CHANGELOG.md | 7 +++++++ lib/generators/test_unit/scaffold/scaffold_generator.rb | 7 +++---- test/integration/user_install_test.sh | 6 +++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aae4aa48..917d8b56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # `tailwindcss-rails` Changelog +## next / unreleased + +### Improved + +* Support Rails 8.1 scaffolding which disables system tests by default. #585 @flavorjones + + ## v4.3.0 / 2025-07-06 ### Improved diff --git a/lib/generators/test_unit/scaffold/scaffold_generator.rb b/lib/generators/test_unit/scaffold/scaffold_generator.rb index c9f16476..511ca7d1 100644 --- a/lib/generators/test_unit/scaffold/scaffold_generator.rb +++ b/lib/generators/test_unit/scaffold/scaffold_generator.rb @@ -4,10 +4,9 @@ module TestUnit # :nodoc: module Generators # :nodoc: class ScaffoldGenerator < Base # :nodoc: def fix_system_test - if turbo_defined? && options[:system_tests] - gsub_file File.join("test/system", class_path, "#{file_name.pluralize}_test.rb"), - /(click_on.*Destroy this.*)$/, - "accept_confirm { \\1 }" + system_test_file = File.join("test/system", class_path, "#{file_name.pluralize}_test.rb") + if turbo_defined? && options[:system_tests] && File.exist?(system_test_file) + gsub_file(system_test_file, /(click_on.*Destroy this.*)$/, "accept_confirm { \\1 }") end end diff --git a/test/integration/user_install_test.sh b/test/integration/user_install_test.sh index c68123ea..46b50560 100755 --- a/test/integration/user_install_test.sh +++ b/test/integration/user_install_test.sh @@ -69,8 +69,12 @@ if [[ $(rails -v) > "Rails 8.0.0.beta" ]] ; then grep -q PasswordsController app/controllers/passwords_controller.rb fi +# TEST: doesn't fail when not generating system tests +bin/rails generate scaffold memo title:string body:text published:boolean --system-tests=false +grep -q "Show" app/views/memos/index.html.erb + # TEST: presence of the generated file -bin/rails generate scaffold post title:string body:text published:boolean +bin/rails generate scaffold post title:string body:text published:boolean --system-tests=true grep -q "Show" app/views/posts/index.html.erb # TEST: the "accept_confirm" system test change was applied cleanly From 5d349ed023f8c3179ab3f9770a21093f93b2a179 Mon Sep 17 00:00:00 2001 From: Sergey Moiseev Date: Thu, 21 Aug 2025 19:01:36 +0300 Subject: [PATCH 42/54] Fix Puma plugin entry point issue --- lib/puma/plugin/tailwindcss.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puma/plugin/tailwindcss.rb b/lib/puma/plugin/tailwindcss.rb index 4624d7e8..3cf777b8 100644 --- a/lib/puma/plugin/tailwindcss.rb +++ b/lib/puma/plugin/tailwindcss.rb @@ -13,7 +13,7 @@ def start(launcher) # If we use system(*command) instead, IRB and Debug can't read from $stdin # correctly bacause some keystrokes will be taken by watch_command. begin - IO.popen(Tailwindcss::Commands.watch_command, 'r+') do |io| + IO.popen(['bin/rails', 'tailwindcss:watch'], 'r+') do |io| IO.copy_stream(io, $stdout) end rescue Interrupt From a6ec1a8e2a6415084fe0e40f150b0810f50576c8 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Mon, 27 Oct 2025 15:57:06 -0400 Subject: [PATCH 43/54] doc: update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 917d8b56..798cb1c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Improved * Support Rails 8.1 scaffolding which disables system tests by default. #585 @flavorjones +* Puma plugin now has experimental support for Rails engines. #567 @bopm ## v4.3.0 / 2025-07-06 From 0d0eed98b708d6e2465267eea7a2cb1e337b249e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Oct 2025 19:58:27 +0000 Subject: [PATCH 44/54] build(deps): bump tailwindcss-ruby from 4.1.11 to 4.1.13 Bumps [tailwindcss-ruby](https://github.com/flavorjones/tailwindcss-ruby) from 4.1.11 to 4.1.13. - [Release notes](https://github.com/flavorjones/tailwindcss-ruby/releases) - [Changelog](https://github.com/flavorjones/tailwindcss-ruby/blob/main/CHANGELOG.md) - [Commits](https://github.com/flavorjones/tailwindcss-ruby/compare/v4.1.11...v4.1.13) --- updated-dependencies: - dependency-name: tailwindcss-ruby dependency-version: 4.1.13 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 5dd291ac..b4f3df2c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -142,11 +142,11 @@ GEM io-console (~> 0.5) securerandom (0.4.1) stringio (3.1.7) - tailwindcss-ruby (4.1.11) - tailwindcss-ruby (4.1.11-aarch64-linux-gnu) - tailwindcss-ruby (4.1.11-arm64-darwin) - tailwindcss-ruby (4.1.11-x86_64-darwin) - tailwindcss-ruby (4.1.11-x86_64-linux-gnu) + tailwindcss-ruby (4.1.13) + tailwindcss-ruby (4.1.13-aarch64-linux-gnu) + tailwindcss-ruby (4.1.13-arm64-darwin) + tailwindcss-ruby (4.1.13-x86_64-darwin) + tailwindcss-ruby (4.1.13-x86_64-linux-gnu) thor (1.3.2) timeout (0.4.3) tzinfo (2.0.6) From 761ce3e1f410cdc8f6eabc046b0acb16363c01ec Mon Sep 17 00:00:00 2001 From: rono23 <26753+rono23@users.noreply.github.com> Date: Fri, 5 Sep 2025 08:33:00 +0900 Subject: [PATCH 45/54] Rename `on_stopped` to `after_stopped` for Puma 7 compatibility --- lib/puma/plugin/tailwindcss.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/puma/plugin/tailwindcss.rb b/lib/puma/plugin/tailwindcss.rb index 3cf777b8..29b5b621 100644 --- a/lib/puma/plugin/tailwindcss.rb +++ b/lib/puma/plugin/tailwindcss.rb @@ -20,7 +20,11 @@ def start(launcher) end end - launcher.events.on_stopped { stop_tailwind } + if Gem::Version.new(Puma::Const::PUMA_VERSION) >= Gem::Version.new("7") + launcher.events.after_stopped { stop_tailwind } + else + launcher.events.on_stopped { stop_tailwind } + end in_background do monitor_tailwind From 937b93f01f12ee8f59e6ca4e2ce4dceb1104da82 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Mon, 27 Oct 2025 16:03:37 -0400 Subject: [PATCH 46/54] doc: update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 798cb1c3..a0c97ed0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * Support Rails 8.1 scaffolding which disables system tests by default. #585 @flavorjones * Puma plugin now has experimental support for Rails engines. #567 @bopm +* Puma plugin uses Puma 7's `after_stopped` callback, quashing a deprecation warning. #578 @rono23 ## v4.3.0 / 2025-07-06 From 289b782749842476b79dc7db3a69522a3e05ec14 Mon Sep 17 00:00:00 2001 From: Tim Lange Date: Wed, 27 Aug 2025 17:08:10 +0200 Subject: [PATCH 47/54] Added docker troubleshooting info to README This adds some troubleshooting information for people that are using docker for their rails instances. Co-authored-by: Mike Dalessio --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 450a177d..f2d60151 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ * [Rails Engines support (Experimental)](#rails-engines-support-experimental) - [Troubleshooting](#troubleshooting) * [The `watch` command is hanging](#the-watch-command-is-hanging) + * [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) * [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) * [Running in a docker container exits prematurely](#running-in-a-docker-container-exits-prematurely) * [Conflict with sassc-rails](#conflict-with-sassc-rails) @@ -428,6 +429,10 @@ There is a [known issue](https://github.com/tailwindlabs/tailwindcss/issues/1724 Please try uninstalling `watchman` and try running the watch task again. +### The `build` command (or `bin/rails assets:precompile`) is hanging inside a docker container + +Without a `WORKDIR`, tailwind may search the entire filesystem for files with CSS class names. So, please make sure your Dockerfile uses a `WORKDIR`. + ### Lost keystrokes or hanging when using terminal-based debugging tools (e.g. IRB, Pry, `ruby/debug`...etc.) with the Puma plugin 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. From 476301daa6cd8f9570a8cc11b4ed0a1136300328 Mon Sep 17 00:00:00 2001 From: Nathaniel Watts Date: Fri, 29 Aug 2025 12:45:13 -0500 Subject: [PATCH 48/54] Update README.md to add context around Tailwind 4 and PostCSS Tailwind 4's CLI tool no longer supports the `--postcss` flag. This updates the documentation to add a note about the change, and hopefully points folks in the right direction. --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index f2d60151..2777cf99 100644 --- a/README.md +++ b/README.md @@ -354,6 +354,9 @@ Than use `@plugin` annotation in `app/assets/tailwind/application.css`: ``` ### Using with PostCSS +> [!NOTE] +> Starting with Tailwind 4, the TailwindCSS CLI tool no longer supports PostCSS out of the box, as the `--postcss` command has been removed. The below information only partains to Tailwind 3. +> If you're wanting to leverage PostCSS with Tailwind 4, you'll likely want to reference [The official Tailwind 4 PostCSS docs](https://tailwindcss.com/docs/installation/using-postcss), and leverage [cssbundling-rails](https://github.com/rails/cssbundling-rails). 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. From 65857184b99598e5f4799c5a19595a7f13dcf8e1 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Mon, 27 Oct 2025 16:22:03 -0400 Subject: [PATCH 49/54] Replace the v3-related postcss docs with a pointer to the v3 branch --- README.md | 42 ++++++++---------------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 2777cf99..3cd46d7c 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ * [Upgrade steps](#upgrade-steps) * [Troubleshooting a v4 upgrade](#troubleshooting-a-v4-upgrade) * [Updating CSS class names for v4](#updating-css-class-names-for-v4) -- [Developing with Tailwindcss](#developing-with-tailwindcss) +- [Developing with TailwindCSS](#developing-with-tailwindcss) * [Configuration and commands](#configuration-and-commands) * [Building for production](#building-for-production) * [Building for testing](#building-for-testing) @@ -44,7 +44,7 @@ With Rails 7 you can generate a new application preconfigured with Tailwind CSS 1. Run `./bin/bundle add tailwindcss-rails` 2. Run `./bin/rails tailwindcss:install` -This gem depends on the `tailwindcss-ruby` gem to install a working Tailwind CLI executable. +This gem depends on the `tailwindcss-ruby` gem to install a working TailwindCSS CLI executable. ### Choosing a specific version of `tailwindcss` @@ -239,7 +239,7 @@ Then, once you've run that successfully, clean up: ``` - **Revert** the changes to `config/tailwind.config.js` so that paths are once again relative to the application root. -## Developing with Tailwindcss +## Developing with TailwindCSS ### Configuration and commands @@ -354,39 +354,13 @@ Than use `@plugin` annotation in `app/assets/tailwind/application.css`: ``` ### Using with PostCSS -> [!NOTE] -> Starting with Tailwind 4, the TailwindCSS CLI tool no longer supports PostCSS out of the box, as the `--postcss` command has been removed. The below information only partains to Tailwind 3. -> If you're wanting to leverage PostCSS with Tailwind 4, you'll likely want to reference [The official Tailwind 4 PostCSS docs](https://tailwindcss.com/docs/installation/using-postcss), and leverage [cssbundling-rails](https://github.com/rails/cssbundling-rails). - -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. - -For example, to enable nesting: - -```js -// postcss.config.js -export default { - plugins: { - "@tailwindcss/postcss": {}, - }, -}; -``` - -⚠ 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: -```json -// package.json -{ - "name": "my app", - "private": true, - "dependencies": { - "@tailwindcss/postcss": "^4.0.0", - "tailwindcss": "^4.0.0", - "postcss": "^8.5.1" - } -} -``` +> [!NOTE] +> Starting with Tailwind v4, the upstream CLI tool no longer supports PostCSS, and the `--postcss` option has +been removed. If you want to leverage PostCSS with Tailwind 3, please reference the [tailwindcss-rails v3 +README](https://github.com/rails/tailwindcss-rails/tree/v3-stable?tab=readme-ov-file#using-with-postcss). -Then you can use yarn or npm to install the dependencies. +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). ### Custom inputs or outputs From df4d44296f83d5ea2463ef063863200f7a261575 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Mon, 27 Oct 2025 16:36:39 -0400 Subject: [PATCH 50/54] deps: bundle update --- Gemfile.lock | 80 +++++++++++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 38 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index b4f3df2c..ef456d2c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,16 +8,16 @@ PATH GEM remote: https://rubygems.org/ specs: - actionmailer (8.0.2) - actionpack (= 8.0.2) - actionview (= 8.0.2) - activejob (= 8.0.2) - activesupport (= 8.0.2) + actionmailer (8.1.0) + actionpack (= 8.1.0) + actionview (= 8.1.0) + activejob (= 8.1.0) + activesupport (= 8.1.0) mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (8.0.2) - actionview (= 8.0.2) - activesupport (= 8.0.2) + actionpack (8.1.0) + actionview (= 8.1.0) + activesupport (= 8.1.0) nokogiri (>= 1.8.5) rack (>= 2.2.4) rack-session (>= 1.0.1) @@ -25,64 +25,65 @@ GEM rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) useragent (~> 0.16) - actionview (8.0.2) - activesupport (= 8.0.2) + actionview (8.1.0) + activesupport (= 8.1.0) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (8.0.2) - activesupport (= 8.0.2) + activejob (8.1.0) + activesupport (= 8.1.0) globalid (>= 0.3.6) - activesupport (8.0.2) + activesupport (8.1.0) base64 - benchmark (>= 0.3) bigdecimal concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + json logger (>= 1.4.2) minitest (>= 5.1) securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) uri (>= 0.13.1) base64 (0.3.0) - benchmark (0.4.1) - bigdecimal (3.2.2) + bigdecimal (3.3.1) builder (3.3.0) concurrent-ruby (1.3.5) - connection_pool (2.5.3) + connection_pool (2.5.4) crass (1.0.6) date (3.4.1) debug (1.11.0) irb (~> 1.10) reline (>= 0.3.8) drb (2.2.3) - erb (5.0.1) + erb (5.1.1) erubi (1.13.1) - globalid (1.2.1) + globalid (1.3.0) activesupport (>= 6.1) i18n (1.14.7) concurrent-ruby (~> 1.0) - io-console (0.8.0) + io-console (0.8.1) irb (1.15.2) pp (>= 0.6.0) rdoc (>= 4.0.0) reline (>= 0.4.2) + json (2.15.2) logger (1.7.0) loofah (2.24.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) - mail (2.8.1) + mail (2.9.0) + logger mini_mime (>= 0.1.1) net-imap net-pop net-smtp mini_mime (1.1.5) mini_portile2 (2.8.9) - minitest (5.25.5) - net-imap (0.5.9) + minitest (5.26.0) + net-imap (0.5.12) date net-protocol net-pop (0.1.2) @@ -91,27 +92,27 @@ GEM timeout net-smtp (0.5.1) net-protocol - nokogiri (1.18.8) + nokogiri (1.18.10) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.18.8-aarch64-linux-gnu) + nokogiri (1.18.10-aarch64-linux-gnu) racc (~> 1.4) - nokogiri (1.18.8-arm-linux-gnu) + nokogiri (1.18.10-arm-linux-gnu) racc (~> 1.4) - nokogiri (1.18.8-arm64-darwin) + nokogiri (1.18.10-arm64-darwin) racc (~> 1.4) - nokogiri (1.18.8-x86_64-darwin) + nokogiri (1.18.10-x86_64-darwin) racc (~> 1.4) - nokogiri (1.18.8-x86_64-linux-gnu) + nokogiri (1.18.10-x86_64-linux-gnu) racc (~> 1.4) - pp (0.6.2) + pp (0.6.3) prettyprint prettyprint (0.2.0) psych (5.2.6) date stringio racc (1.8.1) - rack (3.1.16) + rack (3.2.3) rack-session (2.1.1) base64 (>= 0.1.0) rack (>= 3.0.0) @@ -126,19 +127,21 @@ GEM rails-html-sanitizer (1.6.2) loofah (~> 2.21) nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) - railties (8.0.2) - actionpack (= 8.0.2) - activesupport (= 8.0.2) + railties (8.1.0) + actionpack (= 8.1.0) + activesupport (= 8.1.0) irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) thor (~> 1.0, >= 1.2.2) + tsort (>= 0.2) zeitwerk (~> 2.6) rake (13.3.0) - rdoc (6.14.2) + rdoc (6.15.0) erb psych (>= 4.0.0) - reline (0.6.1) + tsort + reline (0.6.2) io-console (~> 0.5) securerandom (0.4.1) stringio (3.1.7) @@ -147,11 +150,12 @@ GEM tailwindcss-ruby (4.1.13-arm64-darwin) tailwindcss-ruby (4.1.13-x86_64-darwin) tailwindcss-ruby (4.1.13-x86_64-linux-gnu) - thor (1.3.2) + thor (1.4.0) timeout (0.4.3) + tsort (0.2.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - uri (1.0.3) + uri (1.0.4) useragent (0.16.11) zeitwerk (2.7.3) From 1ea1314971899a88e8433861e5dc3918f2432f63 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Mon, 27 Oct 2025 17:03:27 -0400 Subject: [PATCH 51/54] Remove the "poll" option on the watch command which was never supported in Tailwind v4 (only v3). Closes #580 --- CHANGELOG.md | 5 +++++ README.md | 13 +++---------- lib/tailwindcss/commands.rb | 3 +-- lib/tasks/build.rake | 3 +-- test/lib/tailwindcss/commands_test.rb | 8 -------- 5 files changed, 10 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0c97ed0..13daeb69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## next / unreleased +### Changed + +* Removed the "poll" option on the watch command, since Tailwind v4 dropped support for this option (and it has been a no-op in this gem since.) #580 @flavorjones + + ### Improved * Support Rails 8.1 scaffolding which disables system tests by default. #585 @flavorjones diff --git a/README.md b/README.md index 3cd46d7c..a1c2316d 100644 --- a/README.md +++ b/README.md @@ -262,12 +262,13 @@ Synopsis: - `bin/rails tailwindcss:install` - installs the configuration file, output file, and `Procfile.dev` - `bin/rails tailwindcss:build` - generate the output file - `bin/rails tailwindcss:build[debug]` - generate unminimized output + - `bin/rails tailwindcss:build[verbose]` - emit the commands being run - `bin/rails tailwindcss:watch` - start live rebuilds, generating output on file changes - `bin/rails tailwindcss:watch[debug]` - generate unminimized output - - `bin/rails tailwindcss:watch[poll]` - for systems without file system events - `bin/rails tailwindcss:watch[always]` - for systems without TTY (e.g., some docker containers) + - `bin/rails tailwindcss:watch[verbose]` - emit the commands being run -Note that you can combine task options, e.g. `rails tailwindcss:watch[debug,poll]`. +Note that you can combine task options, e.g. `rails tailwindcss:watch[debug,always]`. This gem also makes available a Puma plugin to manage a live rebuild process when you run `rails server` (see "Live Rebuild" section below). @@ -312,14 +313,6 @@ and then running `rails server` (or just `puma`) will run the Tailwind watch pro This is a flexible command, which can be run with a few different options. -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: - -``` -rails tailwindcss:watch[poll] -``` - -(If you use `bin/dev` then you should modify your `Procfile.dev` to use the `poll` option.) - 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. 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`. diff --git a/lib/tailwindcss/commands.rb b/lib/tailwindcss/commands.rb index 99ad30e0..9c910de8 100644 --- a/lib/tailwindcss/commands.rb +++ b/lib/tailwindcss/commands.rb @@ -21,11 +21,10 @@ def compile_command(debug: false, **kwargs) command end - def watch_command(always: false, poll: false, **kwargs) + def watch_command(always: false, **kwargs) compile_command(**kwargs).tap do |command| command << "-w" command << "always" if always - command << "-p" if poll end end diff --git a/lib/tasks/build.rake b/lib/tasks/build.rake index d176f2cd..539a8df9 100644 --- a/lib/tasks/build.rake +++ b/lib/tasks/build.rake @@ -14,11 +14,10 @@ namespace :tailwindcss do desc "Watch and build your Tailwind CSS on file changes" task watch: [:environment, :engines] do |_, args| debug = args.extras.include?("debug") - poll = args.extras.include?("poll") always = args.extras.include?("always") verbose = args.extras.include?("verbose") - command = Tailwindcss::Commands.watch_command(always: always, debug: debug, poll: poll) + command = Tailwindcss::Commands.watch_command(always: always, debug: debug) env = Tailwindcss::Commands.command_env(verbose: verbose) puts "Running: #{Shellwords.join(command)}" if verbose diff --git a/test/lib/tailwindcss/commands_test.rb b/test/lib/tailwindcss/commands_test.rb index d09481a4..62d1e684 100644 --- a/test/lib/tailwindcss/commands_test.rb +++ b/test/lib/tailwindcss/commands_test.rb @@ -111,14 +111,6 @@ def setup refute_includes(actual, "-p") refute_includes(actual, "--minify") - actual = Tailwindcss::Commands.watch_command(poll: true) - assert_kind_of(Array, actual) - assert_equal(executable, actual.first) - assert_includes(actual, "-w") - refute_includes(actual, "always") - assert_includes(actual, "-p") - assert_includes(actual, "--minify") - actual = Tailwindcss::Commands.watch_command(always: true) assert_kind_of(Array, actual) assert_equal(executable, actual.first) From 5520c232deccf5ca946c4427e69f3a7d6be375a5 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Mon, 27 Oct 2025 17:04:06 -0400 Subject: [PATCH 52/54] doc: point to the v3 docs because we're continuing to remove documentation about v3 features --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a1c2316d..320564cd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ # Tailwind CSS for Rails -[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. +[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. + +> [!NOTE] +> 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 +README](https://github.com/rails/tailwindcss-rails/tree/v3-stable?tab=readme-ov-file). From 8253daab851acf9b09beedc46541e30ad898ddc3 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Mon, 27 Oct 2025 17:11:02 -0400 Subject: [PATCH 53/54] version bump to v4.4.0 --- CHANGELOG.md | 2 +- lib/tailwindcss/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13daeb69..d1252a29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # `tailwindcss-rails` Changelog -## next / unreleased +## v4.4.0 / 2025-10-27 ### Changed diff --git a/lib/tailwindcss/version.rb b/lib/tailwindcss/version.rb index 5629f4a4..81738c04 100644 --- a/lib/tailwindcss/version.rb +++ b/lib/tailwindcss/version.rb @@ -1,3 +1,3 @@ module Tailwindcss - VERSION = "4.3.0" + VERSION = "4.4.0" end From 004f23dfa34728f3b545229cc66a9ad66cf469d6 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Mon, 27 Oct 2025 17:28:54 -0400 Subject: [PATCH 54/54] dep: gem version --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index ef456d2c..38faae4c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - tailwindcss-rails (4.3.0) + tailwindcss-rails (4.4.0) railties (>= 7.0.0) tailwindcss-ruby (~> 4.0)