build: add noweb tag to allow building without frontend assets (#5189)

This commit is contained in:
fatedier
2026-03-02 01:32:19 +08:00
committed by GitHub
parent 01997deb98
commit 381245a439
8 changed files with 34 additions and 13 deletions

View File

@@ -29,14 +29,23 @@ var (
prefixPath string
)
type emptyFS struct{}
func (emptyFS) Open(name string) (http.File, error) {
return nil, &fs.PathError{Op: "open", Path: name, Err: fs.ErrNotExist}
}
// if path is empty, load assets in memory
// or set FileSystem using disk files
func Load(path string) {
prefixPath = path
if prefixPath != "" {
switch {
case prefixPath != "":
FileSystem = http.Dir(prefixPath)
} else {
case content != nil:
FileSystem = http.FS(content)
default:
FileSystem = emptyFS{}
}
}