initial commit
This commit is contained in:
commit
23816d00f7
71 changed files with 14497 additions and 0 deletions
31
backend/webui/embed.go
Normal file
31
backend/webui/embed.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// Package webui embeds the compiled React bundle produced by `make build`.
|
||||
//
|
||||
// The `dist` directory is populated by the build pipeline (npm run build copies
|
||||
// frontend/dist into backend/webui/dist). A placeholder index.html is checked
|
||||
// in so the backend always compiles and runs, even in a fresh checkout where
|
||||
// the frontend has not been built yet.
|
||||
package webui
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"io/fs"
|
||||
)
|
||||
|
||||
//go:embed all:dist
|
||||
var assets embed.FS
|
||||
|
||||
// FS returns the root of the embedded bundle, or nil when the placeholder build
|
||||
// is still in place and no real frontend bundle has been compiled.
|
||||
func FS() fs.FS {
|
||||
sub, err := fs.Sub(assets, "dist")
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
if _, err := fs.Stat(sub, "index.html"); err != nil {
|
||||
return nil
|
||||
}
|
||||
return sub
|
||||
}
|
||||
|
||||
// Assets exposes the raw embedded filesystem, including the dist prefix.
|
||||
func Assets() fs.FS { return assets }
|
||||
Loading…
Add table
Add a link
Reference in a new issue