internal/webui carries web/'s build (written to internal/webui/dist by Vite, git-ignored) when sondad is built with -tags webui. Without the tag the app is absent and a plain go build and go test still work with no Node. main wires it into the router.
23 lines
421 B
Go
23 lines
421 B
Go
//go:build webui
|
|
|
|
// Package webui carries the built web app inside the binary.
|
|
package webui
|
|
|
|
import (
|
|
"embed"
|
|
"io/fs"
|
|
)
|
|
|
|
// dist is what `npm run build` writes in web/: build the app first, then build with -tags webui.
|
|
//
|
|
//go:embed all:dist
|
|
var dist embed.FS
|
|
|
|
// FS is the built web app, with index.html at its root.
|
|
func FS() fs.FS {
|
|
sub, err := fs.Sub(dist, "dist")
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
return sub
|
|
}
|