embed assets
This commit is contained in:
parent
bcc93c49cb
commit
e82ed04970
1 changed files with 13 additions and 0 deletions
|
|
@ -1,15 +1,20 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"embed"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"github.com/maddalax/htmgo/framework/h"
|
"github.com/maddalax/htmgo/framework/h"
|
||||||
"github.com/maddalax/htmgo/framework/service"
|
"github.com/maddalax/htmgo/framework/service"
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
|
"io/fs"
|
||||||
"todolist/__htmgo"
|
"todolist/__htmgo"
|
||||||
"todolist/ent"
|
"todolist/ent"
|
||||||
"todolist/infrastructure/db"
|
"todolist/infrastructure/db"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:embed assets/dist/*
|
||||||
|
var StaticAssets embed.FS
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
locator := service.NewLocator()
|
locator := service.NewLocator()
|
||||||
|
|
||||||
|
|
@ -17,10 +22,18 @@ func main() {
|
||||||
return db.Provide()
|
return db.Provide()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
sub, err := fs.Sub(StaticAssets, "assets/dist")
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
h.Start(h.AppOpts{
|
h.Start(h.AppOpts{
|
||||||
ServiceLocator: locator,
|
ServiceLocator: locator,
|
||||||
LiveReload: true,
|
LiveReload: true,
|
||||||
Register: func(e *echo.Echo) {
|
Register: func(e *echo.Echo) {
|
||||||
|
e.StaticFS("/public", sub)
|
||||||
|
|
||||||
e.Static("/public", "./assets/dist")
|
e.Static("/public", "./assets/dist")
|
||||||
__htmgo.Register(e)
|
__htmgo.Register(e)
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue