Fix rails new to use stylesheet_link_tag "application" when --css is present #56086
+14
−1
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.
When generating a Rails app with CSS bundling, e.g.,
rails new myapp --css tailwind --js esbuild, the browser console shows:GET /assets/tailwindcss net::ERR_ABORTED 404 (Not Found)
The problem:
CSS build tools output to
app/assets/builds/application.cssThe generated layout has
stylesheet_link_tag :app, which expands to link tags for ALL .css files in app/assets/:The source file application.tailwind.css shouldn't be served directly: only the built output (application.css) should be linked.
This fix:
using_css_bundling?helper to detect when CSS bundlers are usedRelated: rails/cssbundling-rails#175, rails/cssbundling-rails@1332e42