Add Tailwind CSS v4 support with backward-compatible v3 auto-detection#103
Open
franchb wants to merge 1 commit into
Open
Add Tailwind CSS v4 support with backward-compatible v3 auto-detection#103franchb wants to merge 1 commit into
franchb wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #103 +/- ##
==========================================
+ Coverage 69.63% 69.91% +0.27%
==========================================
Files 36 36
Lines 3188 2599 -589
==========================================
- Hits 2220 1817 -403
+ Misses 919 733 -186
Partials 49 49 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
03d5535 to
a7956a3
Compare
5 tasks
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.
Closes #101
Summary
Adds full Tailwind CSS v4 support to htmgo while maintaining zero-breakage backward compatibility for existing v3 projects.
Key behaviors:
@tailwinddirectives ininput.css, pinned to v3.4.16. No user action needed.tailwind_version: v3.4.16(or any version) inhtmgo.yml.Changes by area
1. Framework config (
framework/config/project.go, 1 line)TailwindVersion stringfield toProjectConfigproject_test.go2. CLI: version resolution + caching (new
cli/htmgo/internal/tailwind/package)version.go:DetectTailwindVersion()(config > input.css auto-detect > "latest"),IsV4(),DownloadURL()cache.go: sidecar__htmgo/tailwind.versionfile for cache invalidation when configured version changes3. CLI: download + invocation (
cli/htmgo/tasks/)css/css.go: version-aware binary download URL, v4 CLI invocation omits-c ./tailwind.config.jsflag, v4 projects don't requiretailwind.config.jsto existcopyassets/bundle.go: skiptailwind.config.jscopy for v4 projects4. Template + example migration
input.cssfiles:@tailwind base/components/utilities→@import "tailwindcss"tailwind.config.jsfiles deleted (v4 uses CSS-first config)hackernews,htmgo-site:@plugin "@tailwindcss/typography"(v4 standalone CLI bundles first-party plugins)todo-list: 19 custom theme colors migrated from JStheme.extend.colorsto CSS@theme { --color-*: ... }variablesBackward compatibility
The auto-detection logic ensures no breakage:
htmgo.ymlhas explicittailwind_version, that takes precedenceinput.csscontains@tailwind(with trailing space — avoids false match on@tailwindcss), version resolves tov3.4.16latest(v4)Note on
go.modThe
TailwindVersionfield lives in theframeworkmodule, which thecli/htmgomodule depends on. Areplacedirective is included so the CLI can reference the local framework during development. After merge to master, the existingupdate-framework-dep.ymlworkflow will automatically rungo getto updatecli/htmgo/go.modto the new framework commit, at which point thereplacedirective can be removed.Test plan
cd framework && go test ./...— all passcd cli/htmgo && go test ./...— 22 new tests + existing all passhtmgo template— should use v4@tailwinddirectives — should auto-detect v3