chore(web): directly read frontend/dist folder but not read it from web folder
This commit is contained in:
+20
-3
@@ -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(".")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user