Skip to content

Commit

Permalink
auto timestamp appcache during build
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan You committed Mar 4, 2013
1 parent e0b1833 commit 4bb3344
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cp $BASEDIR/index.html $BASEDIR/deploy/index.html
cp $BASEDIR/apple-touch-icon-precomposed.png $BASEDIR/deploy/apple-touch-icon-precomposed.png
cp $BASEDIR/offline.appcache $BASEDIR/deploy/offline.appcache

#rewrite index.html for min.js
# rewrite index.html

echo "\033[32m[minify]\033[0m rewriting script tag in" $BASEDIR"/deploy/templates/index.html"
#1. remove all current scripts
Expand All @@ -25,6 +25,9 @@ sed -i.bak 's/<!-- MIN -->/<script src="js\/min.js"><\/script>/' $BASEDIR/deploy
#3. add appcache manifest
sed -i.bak 's/<html>/<html manifest="offline.appcache">/' $BASEDIR/deploy/index.html

# rewrite appcache version
sed -i.bak 's/# build: */# build: '$(date +%s)'/' $BASEDIR/deploy/offline.appcache

#minify javascript with uglifyjs

echo "\033[32m[minify]\033[0m source:" $BASEDIR"/js/"
Expand All @@ -45,13 +48,13 @@ $BASEDIR/js/todo-item.js \
-v -o $BASEDIR/deploy/js/min.js

#remove stuff no longer needed for deploy
echo "\033[33m[cleanup]\033[0m removing stuff no longer needed..."

#1. remove index.html backup
echo "\033[33m[cleanup]\033[0m removing index.html backup..."
rm $BASEDIR/deploy/index.html.bak

#2. remove .DS_Store (if any)
echo "\033[33m[cleanup]\033[0m removing .DS_Store if any..."
#2. remove appcache backup
rm $BASEDIR/deploy/offline.appcache.bak
#3. remove .DS_Store (if any)
find $BASEDIR/deploy -name .DS_Store -exec rm {} \;

echo "\033[31m[done]\033[0m"
2 changes: 1 addition & 1 deletion offline.appcache
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CACHE MANIFEST
# 2013-03-05:v7
# build:

index.html
css/style.css
Expand Down

0 comments on commit 4bb3344

Please sign in to comment.