Fixing issues where cachebuster wasn't working

This commit is contained in:
James Barnsley
2017-01-13 08:23:07 +13:00
parent 030c100c1e
commit 701ca67b5a
2 changed files with 12 additions and 6 deletions

View File

@ -1,18 +1,24 @@
#!/bin/bash
if [ ! -d public_html ]; then
echo -e Creating mopidy_iris/static folder
ln -s mopidy_iris/static public_html
fi
# copy assets
echo -e Copying assets $SERVER
cp src/.htaccess mopidy_iris/static/.htaccess
rsync -avr src/assets/ mopidy_iris/static/assets/
rsync -avrs src/assets/ mopidy_iris/static/assets/ 2>&1 >/dev/null
# create HTML files
echo -e Copying index.html and test.html
cp src/index.html mopidy_iris/static/index.html
cp src/index.html mopidy_iris/static/test.html
# process production html
CACHEBUSTER=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1)
CACHEBUSTER=$(date | md5sum | cut -f1 -d' ')
echo -e Cachebusting js/css URLs $CACHEBUSTER
sed -i 's/app.js/app.min.js?'$CACHEBUSTER'/g' mopidy_iris/static/index.html
sed -i 's/app.css/app.min.css?'$CACHEBUSTER'/g' mopidy_iris/static/index.html
sed -i 's/app.css/app.min.css?'$CACHEBUSTER'/g' mopidy_iris/static/index.html
echo -e "\x1b[32;01m"Done!"\x1b[39;49;00m"

View File

@ -1,6 +1,6 @@
{
"name": "mopidy-iris",
"version": "2.10.12",
"version": "2.10.17",
"description": "Mopidy HTTP interface",
"repository": "https://github.com/jaedb/iris",
"author": "James Barnsley <james@barnsley.nz>",
@ -41,7 +41,7 @@
"react-ga": "2.1.2"
},
"scripts": {
"dev": "./build.sh & NODE_ENV=development webpack",
"prod": "./build.sh & NODE_ENV=production webpack"
"dev": "NODE_ENV=development webpack && ./build.sh",
"prod": "NODE_ENV=production webpack && ./build.sh"
}
}