apache / apache/answer

Vite migration (1/3): Go HTML and asset contract

Offen
#1,579 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Go
Sterne
15.7k
Forks
1.4k
Ø Merge
3 T. 8 Std.
Gemergte PRs (30 T.)
7

Beschreibung

Part of #1578. First step of the series; can land while Create React App still builds.

**Problem.** `internal/controller/template_controller.go` `GetStyle()` scrapes the script and stylesheet paths out of the built `ui/build/index.html` with regexes that require classic scripts with `defer` first and stylesheet links with `href` before `rel`, and it returns a single stylesheet path. Every server-rendered page reuses those paths through `ui/template/header.html`. Any other tag shape returns nothing, and the pages load with no JavaScript and no stylesheet while every build step still reports success. Nothing in the tree asserts the contract.

**Change.** Read the tags from the parsed document (`golang.org/x/net/html`), so attribute order, attribute set and quoting no longer matter. Return `cssPath` as a list, mirroring how script paths are already collected and prefixed, and range over it in `header.html`. Add `TestGetStyleResolvesBuiltAssets`, which calls the real `GetStyle()` against the real embedded build and skips when no build is embedded. Keep the classic `` tag in `header.html`; the module switch belongs to step 2.

**Done when.** `dev` with only this change builds the frontend with the current toolchain, `go build ./...` and `go vet ./...` pass, the test passes against that build, and the served pages are unchanged (one stylesheet, classic scripts).

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Beginne mit internal/controller/template_controller.go und ui/template/header.html und untersuche anschließend den neuen TestGetStyleResolvesBuiltAssets im Vergleich zum eingebetteten Build. Führe den Frontend-Dev-Build gefolgt von go build ./..., go vet ./... und dem Asset-Test aus. Abgeschlossen ist die Aufgabe, wenn geparste Asset-Tags unabhängig von der Reihenfolge der Attribute aufgelöst werden, mehrere Stylesheet-Pfade gerendert werden und ausgelieferte Seiten ein Stylesheet und klassische Skripte beibehalten.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
go, vite
Bereich
backend, build-system, frontend
Issue-Typ
Refactoring
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Aktiv
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
76/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.