initial port of the UI kit
This commit is contained in:
@@ -1,24 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
# Pre-compile step: run the directive codegen, build the Go client to WebAssembly,
|
||||
# and stage the JS shim. Run the dev server instead (go run ./server) for hot
|
||||
# reload; this script is for a one-off/production-style build. Run from anywhere.
|
||||
# Pre-compile step: directive codegen, Tailwind CSS, WebAssembly build, JS shim.
|
||||
# Run the dev server instead (go run ./server) for hot reload; this is for a
|
||||
# one-off/production-style build. Run from anywhere.
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
KJOL_GO="$(cd ../../.. && pwd)"
|
||||
|
||||
echo "==> Generating directive glue (//gowasm:page, //gowasm:layout, //gowasm:server)"
|
||||
go run kjol/cmd/wasmgen ./app
|
||||
|
||||
echo "==> Compiling Tailwind CSS -> wwwroot/app.css (scanning webui + Go markup)"
|
||||
# Run twcss from the kjol module root so the Tailwind engine's deps resolve there
|
||||
# (not in this example module — keeps its go.mod lean).
|
||||
( cd "$KJOL_GO" && 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' )
|
||||
|
||||
echo "==> Compiling ./wasm to wwwroot/app.wasm (GOOS=js GOARCH=wasm)"
|
||||
GOOS=js GOARCH=wasm go build -o wwwroot/app.wasm ./wasm
|
||||
|
||||
echo "==> Copying Go's wasm_exec.js shim into wwwroot/"
|
||||
GOROOT="$(go env GOROOT)"
|
||||
if [ -f "$GOROOT/lib/wasm/wasm_exec.js" ]; then
|
||||
cp "$GOROOT/lib/wasm/wasm_exec.js" wwwroot/wasm_exec.js # Go >= 1.24
|
||||
else
|
||||
cp "$GOROOT/misc/wasm/wasm_exec.js" wwwroot/wasm_exec.js # Go <= 1.23
|
||||
fi
|
||||
shim="$GOROOT/lib/wasm/wasm_exec.js" # Go >= 1.24
|
||||
[ -f "$shim" ] || shim="$GOROOT/misc/wasm/wasm_exec.js" # Go <= 1.23
|
||||
rm -f wwwroot/wasm_exec.js # GOROOT copy is read-only; remove before overwriting
|
||||
cp "$shim" wwwroot/wasm_exec.js
|
||||
chmod u+w wwwroot/wasm_exec.js
|
||||
|
||||
echo "==> Done. Run the server with: go run ./server"
|
||||
echo " then open http://localhost:8085"
|
||||
|
||||
Reference in New Issue
Block a user