Skip to content

Add Tailwind stylesheet component (salvage of #2335) - #2352

Merged
nesquena merged 21 commits into
masterfrom
tailwind-stylesheet-salvage
Oct 14, 2026
Merged

nesquena merged 21 commits into
masterfrom
tailwind-stylesheet-salvage

Conversation

@nesquena

@nesquena nesquena commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

This carries @osbre's commit from #2335 unchanged, plus fixes from review. When squash-merged, it will credit @osbre with a Co-authored-by trailer.

The component (by @osbre): padrino g project --stylesheet=tailwind or padrino g component -c tailwind. It:

  • installs tailwindcss-ruby (the standalone Tailwind v4 binary, so no Node);
  • creates app/stylesheets/application.css and tasks/tailwind.rake (tailwind:build, tailwind:watch);
  • adds a css: line to Procfile.dev, appending to an existing one once;
  • gitignores the build output.

Added in this salvage, each with a test that fails before the change:

  • Re-runs no longer destroy the source. After a build, public/stylesheets/application.css is build output, but re-running the component merged it into the source as if hand-written (an @apply rule 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.
  • Moved styles keep working.
    • @charset and @import lines stay above Tailwind's import.
    • Quoted imports become url() imports, which Tailwind passes through to the build, so they resolve from public/stylesheets as before.
    • A byte order mark or non-UTF-8 bytes no longer break the move.
  • Appended Procfile.dev/.gitignore lines start on a new line, so a file without a trailing newline doesn't get its last line glued to ours. An existing css: process and an edited tasks/tailwind.rake are kept.
  • Pinned tailwindcss-ruby ~> 4.0, since the generated @import "tailwindcss"; is v4-only.
  • A renderer-aware hint for building the CSS and linking it with stylesheet_link_tag 'application', plus a note when switching from sass/scss/less to remove the old engine.
  • Deploys: rake assets:precompile now runs tailwind:build, alongside Vite's assets:precompile when both are used.
  • A CHANGES line, noting Ruby 3.0+ (tailwindcss-ruby's floor).

Verification:

  • The full bundle exec rake test passes 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).
  • Real haml, erb and slim projects were generated, built and booted, and served the CSS.
  • Tested with Vite in both orders: both precompile steps run.
  • Tested under LC_ALL=C.
  • Two review passes ran on the final head.

Not handled: JRuby has no Tailwind binary; set TAILWINDCSS_INSTALL_DIR to a downloaded executable. Mixed macOS/Linux teams need bundle 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

osbre and others added 8 commits October 13, 2026 18:46
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
Copilot AI balanced review requested due to automatic review settings October 14, 2026 08:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

claude added 11 commits October 14, 2026 08:18
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
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
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
@nesquena
nesquena merged commit d31b301 into master Oct 14, 2026
15 checks passed
@nesquena
nesquena deleted the tailwind-stylesheet-salvage branch October 14, 2026 18:34
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 this pull request may close these issues.

4 participants