Skip to content

refactor(buildgen): split css.go into planning, scoping, and minify files#143

Merged
cssbruno merged 1 commit into
mainfrom
refactor/split-buildgen-css
Jun 9, 2026
Merged

refactor(buildgen): split css.go into planning, scoping, and minify files#143
cssbruno merged 1 commit into
mainfrom
refactor/split-buildgen-css

Conversation

@cssbruno

@cssbruno cssbruno commented Jun 9, 2026

Copy link
Copy Markdown
Owner

What

internal/buildgen/css.go had grown to 1,059 lines / 54 functions mixing three unrelated responsibilities. This splits it along its natural seams into focused files — no behavior change, no package boundary change.

File Lines Responsibility
css.go 1,059 → 636 CSS planning: discover/plan page/layout/component CSS, content hashing, output paths
css_scope.go new, 335 Component CSS scoping: keyframe/animation/selector rewriting
css_minify.go new, 104 Dependency-free CSS minifier

Why

css.go was the single genuine outlier in an otherwise well-decomposed package (27 concern-scoped files). The scoping rewriter (~25 funcs) and the minifier are both pure string → string transforms with no dependency on the CSS planning types, so they extract cleanly and make each unit easier to read and test.

Safety

  • Behavior-preserving: code was moved verbatim, not rewritten.
  • Only internal/buildgen/ is touched; no exported/package boundary changes.
  • go build ./..., go vet ./internal/buildgen/, gofmt clean
  • ✅ Full buildgen test suite passes; zero test failures across all 46 module packages

Notes

Pre-existing examples/{login,css,tailwind} build errors (no func main in those config/source fixture dirs) are unrelated to this change.

🤖 Generated with Claude Code

…iles

css.go had grown to 1,059 lines / 54 functions mixing three unrelated
responsibilities. Split along natural seams into focused files:

- css.go (636): CSS planning — discover/plan page/layout/component CSS,
  content hashing, output paths
- css_scope.go (335): component CSS scoping — keyframe/animation/selector
  rewriting
- css_minify.go (104): dependency-free CSS minifier

Both extracted blocks are pure string-to-string transforms with no
dependency on the planning types, so this is behavior-preserving. No
package boundary changes. Full buildgen suite passes; gofmt/vet clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@cssbruno cssbruno merged commit 802ef52 into main Jun 9, 2026
5 checks passed
@cssbruno cssbruno deleted the refactor/split-buildgen-css branch June 9, 2026 18:28
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.

1 participant