build(general): added a version-suffixing step during build to prevent caching of the client files

This commit is contained in:
Will Moss
2024-05-08 09:30:17 +07:00
parent bd18382863
commit 5614249b83
3 changed files with 17 additions and 0 deletions

View File

@@ -22,6 +22,11 @@ npx --yes babel ./client/assets/js/isaiah.js --out-file ./client/assets/js/isaia
# Minify JS
npx --yes terser ./client/assets/js/isaiah.js -o ./client/assets/js/isaiah.js
# Append a version parameter to the main JS & CSS linked files to prevent caching
VERSION=$(git describe --tags --abbrev=0)
sed -i.bak "s/isaiah.js/isaiah.js?v=$VERSION/" ./client/index.html
sed -i.bak "s/style.css/style.css?v=$VERSION/" ./client/index.html
# Build the app
go build -o isaiah main.go
@@ -30,6 +35,9 @@ rm -f ./client/assets/css/tmp.css
rm -f ./client/assets/css/style.css
mv ./client/assets/js/isaiah.backup.js ./client/assets/js/isaiah.js
# Remove backup files
rm -f ./client/index.html.bak
DESTINATION="/usr/bin"
if [ -d "/usr/local/bin" ]; then
DESTINATION="/usr/local/bin"

View File

@@ -8,5 +8,9 @@ rm -f ./client/assets/css/tmp.css
rm -f ./client/assets/css/style.css
mv ./client/assets/js/isaiah.backup.js ./client/assets/js/isaiah.js
# Remove the version parameter from the main JS & CSS linked files
sed -i.bak -E 's/\?v=[0-9.]+//' ./client/index.html
rm -f ./client/index.html.bak
# Remove dist folder generated by goreleaser
rm -rf ./dist/

View File

@@ -20,3 +20,8 @@ npx --yes babel ./client/assets/js/isaiah.js --out-file ./client/assets/js/isaia
# Minify JS
npx --yes terser ./client/assets/js/isaiah.js -o ./client/assets/js/isaiah.js
# Append a version parameter to the main JS & CSS linked files to prevent caching
VERSION=$(git describe --tags --abbrev=0)
sed -i.bak "s/isaiah.js/isaiah.js?v=$VERSION/" ./client/index.html
sed -i.bak "s/style.css/style.css?v=$VERSION/" ./client/index.html