Add js web stuff to landing page + documentation
This commit is contained in:
42
go/cmd/kjol-web/build/main.go
Normal file
42
go/cmd/kjol-web/build/main.go
Normal file
@@ -0,0 +1,42 @@
|
||||
// Command build runs the example's full pre-compile step once: directive codegen,
|
||||
// Tailwind, the wasm binary, and Go's JS shim.
|
||||
//
|
||||
// go run ./build # from go/cmd/kjol-web
|
||||
//
|
||||
// For day-to-day work run the dev server instead (`go run ./server`) — it performs
|
||||
// these same steps on every save and hot-swaps the result into the browser. This
|
||||
// command is for a cold build, CI, or an editor's pre-launch task.
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"kjolweb/buildsteps"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.SetFlags(0)
|
||||
|
||||
steps := []struct {
|
||||
name string
|
||||
run func() ([]byte, error)
|
||||
}{
|
||||
{"generating directive glue (//gowasm:page, //gowasm:layout, //gowasm:server)", buildsteps.Codegen},
|
||||
{"compiling Tailwind CSS -> wwwroot/app.css", buildsteps.Tailwind},
|
||||
{"compiling ./wasm -> wwwroot/app.wasm (GOOS=js GOARCH=wasm)", buildsteps.Wasm},
|
||||
{"bundling the Solid half -> wwwroot/bundle.min.{js,css} (TSX -> Solid -> esbuild)", buildsteps.JS},
|
||||
{"copying Go's wasm_exec.js shim into wwwroot/", buildsteps.Shim},
|
||||
}
|
||||
|
||||
for _, s := range steps {
|
||||
log.Println("==>", s.name)
|
||||
if out, err := s.run(); err != nil {
|
||||
os.Stderr.Write(out)
|
||||
log.Fatalln("build failed:", err)
|
||||
}
|
||||
}
|
||||
|
||||
log.Println("==> Done. Run the server with: go run ./server")
|
||||
log.Println(" then open http://localhost:8085")
|
||||
}
|
||||
Reference in New Issue
Block a user