apache / apache/answer

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

Aperta
#1,579 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Go
Stelle
15.7k
Fork
1.4k
Merge medio
3g 8h
PR unite (30g)
7

Descrizione

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).

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia da internal/controller/template_controller.go e ui/template/header.html, poi esamina il nuovo TestGetStyleResolvesBuiltAssets rispetto alla build incorporata. Esegui la build di sviluppo del frontend, seguita da go build ./..., go vet ./... e dal test degli asset. Il lavoro è completato quando i tag degli asset analizzati vengono risolti indipendentemente dall’ordine degli attributi, vengono renderizzati più percorsi di stylesheet e le pagine servite mantengono uno stylesheet e gli script classici.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
go, vite
Ambito
backend, build-system, frontend
Tipo di issue
Refactoring
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Attiva
Chiarezza
Specificata chiaramente
Idoneità per principianti
76/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.