Files
Agent-System/web/embed.go
T

27 lines
680 B
Go

package web
import (
"embed"
"io/fs"
)
// DistFS holds the production SPA build (npm run build + precompress).
// Build scripts must materialize web/dist before `go build`; the directory is
// gitignored. When dist is absent (fresh checkout / CI vet), patterns embed
// nothing and LookupDist returns false so callers fall back to disk-only mode.
//
//go:embed all:dist
var DistFS embed.FS
// LookupDist returns the embedded dist subtree when the build populated it.
func LookupDist() (fs.FS, bool) {
sub, err := fs.Sub(DistFS, "dist")
if err != nil {
return nil, false
}
if _, err := fs.Stat(sub, "index.html"); err != nil {
return nil, false
}
return sub, true
}