Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4.0.0-rc2 - application.tailwind.css is not ignored by propshaft when using :app or :all flag in stylesheet_link_tag helper #477

Closed
EricGusmao opened this issue Jan 27, 2025 · 8 comments · Fixed by #479

Comments

@EricGusmao
Copy link
Contributor

EricGusmao commented Jan 27, 2025

I am using rails 8.0.1, and after following the steps here using V4.0.0-rc2, the behaviour reported at #470 still persists. The script is running fine, the file moved directories, but it still is compiled and served by propshaft.

Image

Image

This happen due to propshaft stylesheet_link_tag helper Reference.

I just noticed the rake task to upgrade just removes the former stylesheet entry and keeps

<%= stylesheet_link_tag :app, "data-turbo-track": "reload" %>

So all the assets that ends with .css are served.

But If you also remove the line above and add (as the install script):

<%= stylesheet_link_tag "tailwind", "data-turbo-track": "reload" %>

The tailwind unprocessed file is ignored and not served.

@EricGusmao EricGusmao changed the title v4.0.0-rc2 - application.tailwind.css is not ignored by propshaft v4.0.0-rc2 - application.tailwind.css is not ignored by propshaft when using :app or :all flag in stylesheet_link_tag helper Jan 27, 2025
@flavorjones
Copy link
Member

🤔 This was originally fixed in 31621ea, but something I did in the meantime made this regress. Will investigate.

@flavorjones
Copy link
Member

Darn, this is the change that needs to be made, I used after when I should have used before. I'll open a PR.

diff --git a/lib/tailwindcss/engine.rb b/lib/tailwindcss/engine.rb
index 0c020bbc..7b88c5f1 100644
--- a/lib/tailwindcss/engine.rb
+++ b/lib/tailwindcss/engine.rb
@@ -6,7 +6,7 @@ class Engine < ::Rails::Engine
       Rails.application.config.generators.stylesheets = false
     end

-    initializer "tailwindcss.exclude_asset_path", after: "propshaft.append_assets_path" do
+    initializer "tailwindcss.exclude_asset_path", before: "propshaft.append_assets_path" do
       if Rails.application.config.assets.excluded_paths # the app may not be using Propshaft
         Rails.application.config.assets.excluded_paths << Rails.root.join("app/assets/tailwind")
       end

@aeuillot
Copy link

Indeed, i fixed the issue adding config.assets.excluded_paths << Rails.root.join("app/assets/tailwind") in my application.rb.

flavorjones added a commit that referenced this issue Jan 27, 2025

Verified

This commit was signed with the committer’s verified signature.
flavorjones Mike Dalessio
Fixes #477, originally #470 was incompletely fixed.
@flavorjones
Copy link
Member

I think I had tested the original fix on a Rails 7 upgraded app. 🤦

In any case: #479 will fix this and I'll cut another RC release today.

@flavorjones
Copy link
Member

Fixed in https://github.com/rails/tailwindcss-rails/releases/tag/v4.0.0.rc3

@EricGusmao
Copy link
Contributor Author

EricGusmao commented Jan 27, 2025

@flavorjones just tried with rc3 but the issue still persists. but if I add config.assets.excluded_paths << Rails.root.join("app/assets/tailwind") in my application.rb as @aurum-ellt said, the file is properly ignored

@flavorjones
Copy link
Member

flavorjones commented Jan 27, 2025

@EricGusmao OK, then I need help reproducing what you're seeing. A stock rails 8 app generated by the test/integration/user_upgrade_journey.sh works fine.

@EricGusmao
Copy link
Contributor Author

@flavorjones It's working fine, it was a problem on my end, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants