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:
parent
ef777936d2
commit
456adce73b
2 changed files with 23 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
dist/
|
||||
22
Makefile
Normal file
22
Makefile
Normal 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/
|
||||
Loading…
Add table
Reference in a new issue