initial port of the UI kit
This commit is contained in:
Binary file not shown.
@@ -31,7 +31,7 @@ func main() {
|
||||
Addr: *addr,
|
||||
Dir: "./wwwroot",
|
||||
Watch: *watch,
|
||||
WatchDirs: []string{"app", "wasm", "../../../vdom", "../../../wasmruntime", "../../../rsc"}, // example + kjol engine
|
||||
WatchDirs: []string{"app", "wasm", "css", "../../../webui", "../../../vdom", "../../../wasmruntime", "../../../rsc"}, // example + kjol engine + kit
|
||||
Build: buildWasm,
|
||||
Render: render,
|
||||
Document: document,
|
||||
@@ -59,23 +59,37 @@ func document(inner string) string {
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>gowasm — a tiny Blazor-like engine</title>
|
||||
<link rel="stylesheet" href="/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="/app.css" />
|
||||
</head>
|
||||
<body>
|
||||
<body class="bg-neutral-50 text-neutral-900 antialiased">
|
||||
<div id="app">` + inner + `</div>
|
||||
<script src="/wasm_exec.js"></script>
|
||||
<script src="/bootstrap.js"></script>
|
||||
<script src="/wasmboot.js"></script>
|
||||
</body>
|
||||
</html>`
|
||||
}
|
||||
|
||||
// buildWasm runs the directive codegen (kjol/cmd/wasmgen), then compiles
|
||||
// ./wasm to wwwroot/app.wasm. Returned combined output is shown in the browser
|
||||
// overlay on failure.
|
||||
// buildWasm runs the directive codegen (kjol/cmd/wasmgen), compiles the Tailwind
|
||||
// CSS (kjol/cmd/twcss, scanning the Go markup + webui kit), then compiles ./wasm
|
||||
// to wwwroot/app.wasm. Returned combined output is shown in the browser overlay
|
||||
// on failure.
|
||||
func buildWasm() ([]byte, error) {
|
||||
if out, err := exec.Command("go", "run", "kjol/cmd/wasmgen", "./app").CombinedOutput(); err != nil {
|
||||
return out, err
|
||||
}
|
||||
// Compile Tailwind from the kjol module root (so the engine's deps resolve),
|
||||
// scanning the webui kit + this example's Go markup for utility candidates.
|
||||
tw := exec.Command("go", "run", "./cmd/twcss",
|
||||
"-entry", "cmd/examples/go-wasm-web/css/app.css",
|
||||
"-out", "cmd/examples/go-wasm-web/wwwroot/app.css",
|
||||
"-base", ".",
|
||||
"webui/**/*.go",
|
||||
"cmd/examples/go-wasm-web/app/**/*.go",
|
||||
"cmd/examples/go-wasm-web/server/**/*.go")
|
||||
tw.Dir = "../../.." // kjol/go
|
||||
if out, err := tw.CombinedOutput(); err != nil {
|
||||
return out, err
|
||||
}
|
||||
cmd := exec.Command("go", "build", "-o", filepath.Join("wwwroot", "app.wasm"), "./wasm")
|
||||
cmd.Env = append(os.Environ(), "GOOS=js", "GOARCH=wasm")
|
||||
return cmd.CombinedOutput()
|
||||
|
||||
Reference in New Issue
Block a user