42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
// 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 cmd/examples/go-wasm-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"
|
|
|
|
"gowasmweb/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},
|
|
{"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")
|
|
}
|