diff options
Diffstat (limited to 'postbuild.sh')
-rwxr-xr-x | postbuild.sh | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/postbuild.sh b/postbuild.sh new file mode 100755 index 0000000..c1f0ffc --- /dev/null +++ b/postbuild.sh @@ -0,0 +1,33 @@ +#!/bin/bash +PUBLISH_URL="/hoverbit-ble/" + +cd "dist" || exit 1 + +VERSION=$(cat ../package.json \ + | grep version \ + | head -1 \ + | awk -F: '{ print $2 }' \ + | sed 's/[",]//g' \ + | tr -d '[[:space:]]') + +tput setaf 4; echo "> Add service-worker.js..."; tput sgr0 +cp ../src/service-worker.js ./service-worker.js + +tput setaf 4; echo "> Add version number to files ($VERSION)..."; tput sgr0 +sed -i".bak" "s/{{ VERSION }}/$VERSION/g" index.html +sed -i".bak" "s/{{ VERSION }}/$VERSION/g" service-worker.js + +tput setaf 4; echo "> Add cache-files to webmanifest..."; tput sgr0 +cache_files="'$PUBLISH_URL'"; +for file in *; do + if [[ "$file" =~ (manifest.webmanifest|*.git) ]]; then + continue + fi + cache_files="$cache_files,""'$PUBLISH_URL$file'" +done +sed -i".bak" "s|\"{{ CACHE_FILES }}\"|$cache_files|g" service-worker.js + +tput setaf 4; echo "> Remove .bak-files..."; tput sgr0 +rm *.bak + +cd .. |