build: add Makefile with WASM build target and size check

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Claude 2026-02-17 00:15:08 +00:00
parent ef777936d2
commit 456adce73b
No known key found for this signature in database
GPG key ID: AF404715446AEB41
2 changed files with 23 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
dist/

22
Makefile Normal file
View file

@ -0,0 +1,22 @@
.PHONY: wasm test clean
WASM_OUT := dist/go-html.wasm
test:
go test ./...
wasm: $(WASM_OUT)
$(WASM_OUT):
@mkdir -p dist
GOOS=js GOARCH=wasm go build -ldflags="-s -w" -o $(WASM_OUT) ./cmd/wasm/
@ls -lh $(WASM_OUT)
@SIZE=$$(stat -c%s "$(WASM_OUT)" 2>/dev/null || stat -f%z "$(WASM_OUT)"); \
if [ "$$SIZE" -gt 2097152 ]; then \
echo "WARNING: WASM binary exceeds 2MB target ($${SIZE} bytes)"; \
else \
echo "OK: WASM binary within 2MB target ($${SIZE} bytes)"; \
fi
clean:
rm -rf dist/