fast hmr
This commit is contained in:
parent
fe409c363c
commit
b102bd754b
3 changed files with 12 additions and 11 deletions
|
|
@ -96,6 +96,7 @@ func KillAll() {
|
||||||
}
|
}
|
||||||
|
|
||||||
commands = make([]*exec.Cmd, 0)
|
commands = make([]*exec.Cmd, 0)
|
||||||
|
fmt.Printf("all processes killed\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func PidExists(pid int32) (bool, error) {
|
func PidExists(pid int32) (bool, error) {
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,7 @@ func OnFileChange(events []*fsnotify.Event) {
|
||||||
|
|
||||||
if c.HasAnySuffix("tailwind.config.js", ".css") {
|
if c.HasAnySuffix("tailwind.config.js", ".css") {
|
||||||
tasks.Css = true
|
tasks.Css = true
|
||||||
|
tasks.Run = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.HasAnyPrefix("ent/schema") {
|
if c.HasAnyPrefix("ent/schema") {
|
||||||
|
|
@ -95,12 +96,6 @@ func OnFileChange(events []*fsnotify.Event) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if tasks.Css {
|
|
||||||
deps = append(deps, func() any {
|
|
||||||
return css.GenerateCss(false)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if tasks.Ent {
|
if tasks.Ent {
|
||||||
deps = append(deps, func() any {
|
deps = append(deps, func() any {
|
||||||
run.EntGenerate()
|
run.EntGenerate()
|
||||||
|
|
@ -123,8 +118,13 @@ func OnFileChange(events []*fsnotify.Event) {
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
|
process.KillAll()
|
||||||
|
|
||||||
|
if tasks.Css {
|
||||||
|
go css.GenerateCss(false)
|
||||||
|
}
|
||||||
|
|
||||||
if tasks.Run {
|
if tasks.Run {
|
||||||
process.KillAll()
|
|
||||||
_ = run.Server(false)
|
_ = run.Server(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import (
|
||||||
func IndexPage(c echo.Context) *h.Page {
|
func IndexPage(c echo.Context) *h.Page {
|
||||||
return h.NewPage(h.Html(
|
return h.NewPage(h.Html(
|
||||||
h.HxExtension(base.Extensions()),
|
h.HxExtension(base.Extensions()),
|
||||||
h.Class("bg-slate-100 flex flex-col items-center h-full w-full"),
|
h.Class("bg-red-200 flex flex-col items-center h-full w-full"),
|
||||||
h.Head(
|
h.Head(
|
||||||
h.Link("/public/main.css", "stylesheet"),
|
h.Link("/public/main.css", "stylesheet"),
|
||||||
h.Script("/public/htmgo.js"),
|
h.Script("/public/htmgo.js"),
|
||||||
|
|
@ -21,7 +21,7 @@ func IndexPage(c echo.Context) *h.Page {
|
||||||
h.Class("flex flex-col items-center justify-center gap-6 p-12 text-center"),
|
h.Class("flex flex-col items-center justify-center gap-6 p-12 text-center"),
|
||||||
h.H1(
|
h.H1(
|
||||||
h.Class("text-4xl sm:text-5xl font-bold max-w-3xl"),
|
h.Class("text-4xl sm:text-5xl font-bold max-w-3xl"),
|
||||||
h.Text("test"),
|
h.Text("changed this"),
|
||||||
),
|
),
|
||||||
h.P(
|
h.P(
|
||||||
h.Class("text-lg sm:text-xl max-w-1xl"),
|
h.Class("text-lg sm:text-xl max-w-1xl"),
|
||||||
|
|
@ -35,8 +35,8 @@ func IndexPage(c echo.Context) *h.Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Button() h.Renderable {
|
func Button() h.Renderable {
|
||||||
return h.Button(h.Class("btn bg-red-500 p-4 rounded text-white"),
|
return h.Button(h.Class("btn bg-green-500 p-4 rounded text-white"),
|
||||||
h.Text("this is my nice this works"),
|
h.Text("my button"),
|
||||||
h.AfterRequest(
|
h.AfterRequest(
|
||||||
h.SetDisabled(true),
|
h.SetDisabled(true),
|
||||||
h.RemoveClass("bg-red-600"),
|
h.RemoveClass("bg-red-600"),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue