Skip to content

Commit

Permalink
hash in build -- can serve from public dir
Browse files Browse the repository at this point in the history
  • Loading branch information
reinhrst committed Nov 27, 2023
1 parent 0ddba08 commit e30e476
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ LIBAVJS_BASE_FILES := \
behave.dbg.simd.wasm
LIBAVJS_MAKE_FILES := $(addprefix dist/libav-$(LIBAVJS_VERSION)-, $(LIBAVJS_BASE_FILES)) dist/libav.types.d.ts
LIBAVJS_TARGET_FILES := $(addprefix public/app/bundled/libavjs/, $(LIBAVJS_MAKE_FILES))
HTML_FILES := $(wildcard *.html)
HTML_TARGET_FILES := $(addprefix public/, $(HTML_FILES))
ENTRYPOINTS := $(shell node -p "require('./tsconfig.json').include.filter(x => !x.endsWith('.d.ts')).join(' ')")
OUTFILESBASE := $(basename $(ENTRYPOINTS:./src/%=app/%))

.PHONY=all

all: public/app/tsc public/app/bundled/libavjs/empty public/app/bundled/tfjs-wasm
all: public/app/tsc public/app/bundled/libavjs/empty public/app/bundled/tfjs-wasm $(HTML_TARGET_FILES)

public/app/bundled/libavjs/empty: $(LIBAVJS_TARGET_FILES)
@touch $@
Expand All @@ -29,8 +33,11 @@ $(LIBAVJS_TARGET_FILES): libav.js/Dockerfile

public/app/tsc: tsconfig.json $(shell find src) public/app/bundled/libavjs/empty
@tsc --noEmit
@./node_modules/esbuild/bin/esbuild $$(node -p "require('./tsconfig.json').include.join(' ')") --sourcemap --bundle --format=esm --outdir=public/app/
touch $@
@./node_modules/esbuild/bin/esbuild $(ENTRYPOINTS) --sourcemap --bundle --format=esm --outbase=src --outdir=public/app/
@(cd public $(foreach ext,js css,$(foreach outfilebase,$(OUTFILESBASE),&& MD5=$$(md5sum "$(outfilebase).$(ext)" | cut -c-10) && mv "$(outfilebase).$(ext)" "$(outfilebase).$${MD5}.$(ext)" && echo "s|$(outfilebase).$(ext)|$(outfilebase).$${MD5}.$(ext)|g"))) > $@

$(HTML_TARGET_FILES): public/%.html: %.html public/app/tsc
@sed -f public/app/tsc < $< > $@

public/app/bundled/tfjs-wasm: $(wildcard node_modules/@tensorflow/tfjs-backend-wasm/dist/*.wasm)
@mkdir -p $@
Expand Down
8 changes: 4 additions & 4 deletions convert.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!doctype html>
<html>
<head>
<script type="text/javascript">LibAV = {base: "/public/app/bundled/libavjs/dist/"};</script>
<script type="text/javascript" src="public/app/bundled/libavjs/dist/libav-4.6.6.0.1-behave.dbg.js"></script>
<script type="module" src="public/app/convert/App.js"></script>
<link rel="stylesheet" href="public/app/convert/App.css">
<script type="text/javascript">LibAV = {base: "app/bundled/libavjs/dist/"};</script>
<script type="text/javascript" src="app/bundled/libavjs/dist/libav-4.6.6.0.1-behave.dbg.js"></script>
<script type="module" src="app/convert/App.js"></script>
<link rel="stylesheet" href="app/convert/App.css">
</head>
<body>
</body>
Expand Down

0 comments on commit e30e476

Please sign in to comment.