foxfiles/frontend/frontend.go
2024-02-01 21:32:10 +01:00

37 lines
687 B
Go

package frontend
import (
"embed"
"html/template"
"os"
vueglue "github.com/torenware/vite-go"
)
//go:embed dist
var FS embed.FS
//go:embed index.html
var tmpl string
var Template = template.Must(template.New("index").Parse(tmpl))
func Glue(dev bool) (*vueglue.VueGlue, error) {
if dev {
return vueglue.NewVueGlue(&vueglue.ViteConfig{
Environment: "development",
AssetsPath: "frontend",
EntryPoint: "src/main.ts",
Platform: "svelte",
FS: os.DirFS("frontend"),
})
}
return vueglue.NewVueGlue(&vueglue.ViteConfig{
Environment: "production",
AssetsPath: ".",
EntryPoint: "src/main.ts",
Platform: "svelte",
FS: FS,
})
}