23 lines
753 B
Bash
Executable File
23 lines
753 B
Bash
Executable File
#!/bin/sh
|
|
|
|
SHA=$(git rev-parse --short HEAD)
|
|
|
|
# Build to a temporary file
|
|
bun build ./src/js/main.js \
|
|
--outfile ./public/bundle.tmp.js \
|
|
--target browser
|
|
|
|
# If bundle.js doesn't exist yet, fake it it
|
|
if [ ! -f ./public/bundle.js ]; then
|
|
touch ./public/bundle.js
|
|
fi
|
|
|
|
# Strip version comments from both files and compare
|
|
tail -n +4 ./public/bundle.js > ./public/bundle.old.content.tmp
|
|
tail -n +1 ./public/bundle.tmp.js > ./public/bundle.new.content.tmp
|
|
|
|
if ! cmp -s ./public/bundle.old.content.tmp ./public/bundle.new.content.tmp; then
|
|
printf "////\n// version: %s\n\n" "$SHA" | cat - ./public/bundle.tmp.js > ./public/bundle.js
|
|
fi
|
|
|
|
rm ./public/bundle.tmp.js ./public/bundle.old.content.tmp ./public/bundle.new.content.tmp |