-
Notifications
You must be signed in to change notification settings - Fork 0
/
minify.bash
executable file
·61 lines (53 loc) · 969 Bytes
/
minify.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
WEBROOT=`pwd`
YUI=${WEBROOT}/_assets/yuicompressor-2.4.8.jar
HTML=${WEBROOT}/_assets/htmlcompressor-1.5.3.jar
function globexists {
test -e "$1" -o -L "$1"
}
minimizeHTML () {
if globexists *.html
then
for h in `ls *.html`
do
echo Minifying HTML in: $h
java -jar $HTML -o TMP $h
mv TMP $h
done
fi
}
###################
# Minify the HTML
pushd _site > /dev/null
minimizeHTML
for dir in `ls`
do
if [ -d $dir ]
then
echo Moving into "[ $dir ]" to minimize HTML;
pushd $dir > /dev/null
minimizeHTML
popd > /dev/null
fi
done
popd > /dev/null
###################
# Minify the CSS files
echo Minimizing CSS files
pushd _site/css > /dev/null
for i in `ls *.css`
do
echo Minifying $i;
java -jar ${YUI} $i > TMP
mv tmp $i
done
popd > /dev/null
# Minify the JS files
#pushd _site/js
#for i in `ls *.js`
#do
# echo $i;
# java -jar ${YUI} $i > TMP
# mv tmp $i
#done
#popd