Repository navigation
Add Tailwind stylesheet component (salvage of #2335) - #2352
Merged
Merged
Conversation
After a build, public/stylesheets/application.css is Tailwind's output, so re-running the component merged the minified build into app/stylesheets/application.css and overwrote the hand-written source. Only migrate public styles when there is no source yet; otherwise skip. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JWpdhd1LepyfkNRGx9kwrD
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JWpdhd1LepyfkNRGx9kwrD
The generated source uses `@import "tailwindcss";`, which only Tailwind v4 understands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JWpdhd1LepyfkNRGx9kwrD
After setup, print the build command and the stylesheet_link_tag line for the project's renderer, like the Vite component does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JWpdhd1LepyfkNRGx9kwrD
Deploy platforms run assets:precompile, and the build output is gitignored, so make it depend on tailwind:build. Rake appends prerequisites, so this coexists with other assets:precompile tasks such as vite_ruby's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JWpdhd1LepyfkNRGx9kwrD
Thor's append_file already skips content that is present, so re-running the component leaves Procfile.dev and .gitignore unchanged; guard that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JWpdhd1LepyfkNRGx9kwrD
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JWpdhd1LepyfkNRGx9kwrD
A Procfile.dev or .gitignore without a trailing newline had the line
glued onto its last line ("web: bundle exec pumacss: ...").
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JWpdhd1LepyfkNRGx9kwrD
Adding Tailwind to a project whose Procfile.dev already runs a css: process added a second one, as the Vite component avoids for vite:. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JWpdhd1LepyfkNRGx9kwrD
…ilwind Moving a hand-written public/stylesheets/application.css below @import "tailwindcss" put its @import lines after Tailwind's rules, where browsers ignore them, and left relative imports such as reset.css unresolvable from app/stylesheets, so rake tailwind:build failed. Hoist the leading @charset/@import block above the Tailwind import and point relative imports at ../../public/stylesheets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JWpdhd1LepyfkNRGx9kwrD
Without a terminal, Thor answers the overwrite prompt with yes, so a re-run replaced an edited rake file. Skip it like the source file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JWpdhd1LepyfkNRGx9kwrD
Switching from sass, scss or less left their gems and initializer in place, still compiling into public/stylesheets, which Tailwind now writes to. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JWpdhd1LepyfkNRGx9kwrD
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JWpdhd1LepyfkNRGx9kwrD
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JWpdhd1LepyfkNRGx9kwrD
# Conflicts: # CHANGES.rdoc
Tailwind inlines quoted imports from the source's folder but passes url() imports through to the build, so rewriting paths broke url() imports (404 at /public/stylesheets/...) and quoted absolute ones (build error). Turn every quoted import into a url() import instead, so each resolves as before and none is inlined after other rules. Read the file as bytes and drop a byte order mark, so a BOM or a non-UTF-8 file no longer breaks the move. When switching from sass, scss or less, public/stylesheets/application.css is compiled output, so don't copy it into the Tailwind source. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JWpdhd1LepyfkNRGx9kwrD
…mpiles them
Switching from a preprocessor skipped the move even when the project had no
app/stylesheets/application.{sass,scss,less}, so the first Tailwind build
overwrote hand-written public CSS.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JWpdhd1LepyfkNRGx9kwrD
# Conflicts: # CHANGES.rdoc
Dir[] read brackets or braces in the project path as glob syntax, so it missed an existing application.scss there and moved compiled output into the source. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JWpdhd1LepyfkNRGx9kwrD
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 carries @osbre's commit from #2335 unchanged, plus fixes from review. When squash-merged, it will credit @osbre with a
Co-authored-bytrailer.The component (by @osbre):
padrino g project --stylesheet=tailwindorpadrino g component -c tailwind. It:tailwindcss-ruby(the standalone Tailwind v4 binary, so no Node);app/stylesheets/application.cssandtasks/tailwind.rake(tailwind:build,tailwind:watch);css:line toProcfile.dev, appending to an existing one once;Added in this salvage, each with a test that fails before the change:
public/stylesheets/application.cssis build output, but re-running the component merged it into the source as if hand-written (an@applyrule was lost). Public styles are now moved only when no source exists yet. The same applies when switching from sass/scss/less: compiled output isn't copied over if a preprocessor source exists. Hand-written CSS in a project without one is still moved.@charsetand@importlines stay above Tailwind's import.url()imports, which Tailwind passes through to the build, so they resolve frompublic/stylesheetsas before.Procfile.dev/.gitignorelines start on a new line, so a file without a trailing newline doesn't get its last line glued to ours. An existingcss:process and an editedtasks/tailwind.rakeare kept.tailwindcss-ruby ~> 4.0, since the generated@import "tailwindcss";is v4-only.stylesheet_link_tag 'application', plus a note when switching from sass/scss/less to remove the old engine.rake assets:precompilenow runstailwind:build, alongside Vite'sassets:precompilewhen both are used.Verification:
bundle exec rake testpasses in an isolated environment, plain and with--enable-frozen-string-literal(padrino-gen 275 runs, 0 failures, on top of master with Add Vite script component (salvage of #2334) #2351).LC_ALL=C.Not handled: JRuby has no Tailwind binary; set
TAILWINDCSS_INSTALL_DIRto a downloaded executable. Mixed macOS/Linux teams needbundle lock --add-platform x86_64-linux. Both go in the padrino-docs follow-up.Closes #2335.
🤖 Generated with Claude Code
https://claude.ai/code/session_01JWpdhd1LepyfkNRGx9kwrD