Add TAILWINDCSS_SKIP_BUILD to skip the Tailwind build during asset compilation#627
Open
cgmoore120 wants to merge 1 commit into
Open
Add TAILWINDCSS_SKIP_BUILD to skip the Tailwind build during asset compilation#627cgmoore120 wants to merge 1 commit into
cgmoore120 wants to merge 1 commit into
Conversation
Member
|
@cgmoore120 Thanks for the pull request. I'm not opposed to doing something to omit tailwind compilation, but I do want to make sure we're fixing it in the right place. I am very curious why the tailwind assets are being treated differently from other assets with respect to points 1 and 2 above:
I don't think these are common idioms with Rails, but if I'm wrong then my instinct would be to start a discussion on whether the |
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.
Summary
The gem unconditionally enhances
assets:precompile(and the test prepare task) withtailwindcss:build, so the Tailwind build runs automatically before assets are digested or tests are prepared. There is currently no supported way to opt out of this.This adds a
TAILWINDCSS_SKIP_BUILDenvironment variable: when set to any non-blank value, the automatic enhancement is skipped. Default behavior is unchanged when the variable is unset or blank, so this is fully backward-compatible.Motivation
A few situations where running the Tailwind build automatically is undesirable:
app/assets/builds/tailwind.cssahead of time and don't wantassets:precompileto rebuild (and potentially overwrite) it.assets:precompilewastes time and defeats layer caching.arm64host producing anamd64image via emulation), the standalone CLI can fail to produce correct output. There is a known float-truncation issue in this area on Apple Silicon / Rosetta with Bun (see oven-sh/bun#19677 and tailwindlabs/tailwindcss#17728). This isn't a bug in this gem, but being able to skip the automatic build lets users build the CSS in a context where it works and skip it where it doesn't.Precedent
The gem already reads an environment flag in the same idiom:
ENV["TAILWINDCSS_DEBUG"].present?inlib/tailwindcss/commands.rb. This change uses the same.present?check for consistency.Changes
enhance(...)block inlib/tasks/build.rakeinunless ENV["TAILWINDCSS_SKIP_BUILD"].present?.TAILWINDCSS_DEBUGdocs.tailwindcss:buildis attached toassets:precompileandtest:prepareby default, that it is not attached whenTAILWINDCSS_SKIP_BUILDis set, and that a blank value does not skip the build.Testing
bundle exec rake testpasses (30 runs, 214 assertions, 0 failures, 0 errors, 0 skips).