chore(web): directly read frontend/dist folder but not read it from web folder

This commit is contained in:
2026-09-10 20:51:11 +08:00
parent 2cfd871780
commit 23fc14cc17
2 changed files with 29 additions and 9 deletions
+20 -3
View File
@@ -1,6 +1,23 @@
package web
import "embed"
import (
"io/fs"
"os"
"path/filepath"
)
//go:embed dist/*
var StaticFiles embed.FS
// StaticFiles is the built frontend, rooted at the directory Vite writes to
// (frontend/dist), so paths inside it are relative to that directory, e.g.
// "index.html" or "assets/app.js". The path is relative to the working
// directory, so the server is expected to run from the repository root.
var StaticFiles fs.FS
func init() {
dir := filepath.Join("frontend", "dist")
if _, err := os.Stat(dir); err == nil {
StaticFiles = os.DirFS(dir)
return
}
StaticFiles = os.DirFS(".")
}