From 15a1d5c6deb955075b7208d1f7e9594a3da68523 Mon Sep 17 00:00:00 2001 From: Robert Garrett Date: Thu, 6 Nov 2025 10:17:32 -0600 Subject: [PATCH] New build variants: "standalone" and "bundle-able" The `web-standalone` target does what the old `web` target did: Produce the WASM, JS, and an index.html so the output can be served up directly. The new `web` target renames the "index.html" to "boids.html" so it can be used as a submodule/subpage in a larger website build. --- Makefile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3aafe6e1..e3dedad1 100644 --- a/Makefile +++ b/Makefile @@ -10,9 +10,14 @@ CARGO_PROFILE := wasm-release SRC_DIR = ./src SRCS := $(wildcard $(SRC_DIR)/**) -.PHONY: clean full-clean web tarball +.PHONY: clean full-clean tarball tarball-standalone web web-standalone -web: out/boids.js out/boids_bg.wasm out/index.html +# "Standalone" version +# (i.e., it includes an index.html so it can be placed on a server as-is) +web-standalone: out/boids.js out/boids_bg.wasm out/index.html + +# "Bundle-able" version. The host site must provide it's own HTML page. +web: out/boids.js out/boids_bg.wasm out/boids.html tarball: boids_web_root.tar @@ -30,9 +35,14 @@ out: out/boids.js out/boids_bg.wasm &: target/$(CARGO_TARGET)/$(CARGO_PROFILE)/another-boids-in-rust.wasm | out wasm-bindgen --no-typescript --target web --out-dir ./out/ --out-name boids target/$(CARGO_TARGET)/$(CARGO_PROFILE)/another-boids-in-rust.wasm +# Copies the index page to the output out/index.html: www/index.html cp -a $< $@ +# Like `out/index.html`, but renames it for use in a larger site. +out/boids.html: www/index.html + cp -a $< $@ + # Clean the web build, but not the Cargo cache. Cargo handles it's own caching # and I don't want to obliterate it all the time. clean: