Conversation
Migrate TailwindCSS config to v4 native @source directives
Comment on lines
+3
to
+5
| @source '../../../app/helpers/**/*.rb'; | ||
| @source '../../../app/components/**/*.{erb,haml,html,slim,rb}'; | ||
| @source '../../../config/initializers/**/*.rb'; |
Contributor
There was a problem hiding this comment.
Bug: Relying on implicit TailwindCSS content detection may cause CSS classes from views and JavaScript to be purged, breaking application styles.
Severity: MEDIUM
Suggested Fix
To ensure all necessary CSS classes are retained, explicitly re-add the @source directives for view and JavaScript files in app/assets/tailwind/application.css. For example: @source "app/views/**/*.erb"; and @source "app/javascript/**/*.js";.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: app/assets/tailwind/application.css#L3-L5
Potential issue: The removal of explicit `@source` directives for `app/views/**/*.erb`
and `app/javascript/**/*.js` relies on the automatic content detection of TailwindCSS
v4. While this is designed to work with Rails, there's a risk that the
`tailwindcss-ruby` integration with the asset pipeline may not discover all content
paths correctly. If auto-detection fails, Tailwind classes used in ERB templates or
dynamically added via JavaScript (e.g., in
`app/javascript/controllers/email_autocomplete_controller.js`) will be purged during the
production build, leading to widespread styling breakages across the application.
Did we get this right? 👍 / 👎 to inform future reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request updates how Tailwind CSS sources content for class scanning and configuration. The main change is moving the content source configuration from
tailwind.config.jsinto theapplication.cssfile, streamlining the setup and potentially making it easier to manage Tailwind's purging behavior directly within the stylesheet.Tailwind CSS configuration updates:
content,plugins, andsafelistconfiguration fromconfig/tailwind.config.js, eliminating the need for explicit file path listings in the JS config.@sourcedirectives toapp/assets/tailwind/application.cssto specify which files Tailwind should scan for class usage, including helpers, components, and initializers.# Pull RequestDescription
Related Issues
Type of Change
How Has This Been Tested?
Checklist