blob: 80bc7b919b69c8d08859643fb748898343eaee8b (
plain)
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
|
#!/bin/sh
TARGET="$1"
VER="$2"
MINIFY_FLAGS="--html-keep-document-tags --html-keep-whitespace --recursive"
if [ -z "$TARGET" -o -z "$VER" ]; then
echo "Usage: $0 <target> <ver>"
echo "Either <target> or <ver> is missing. Exiting."
exit 1
fi
if ! [ -d "$TARGET" ]; then
echo "Target directory $TARGET does not exist. Exiting."
exit 1
fi
# Check if minify is in the PATH
which minify > /dev/null 2>&1
# Check if the previous command has a 0 exit status
if [ $? -eq 0 ]
then
MINIFY_BIN=$(which minify)
else
# Backwards compatibility
if [ -f /scripts/minify ]
then
MINIFY_BIN=/scripts/minify
else
echo "minify binary not found in PATH. Exiting."
exit 1
fi
fi
# Minify assets
printf "Optimizing assets..."
printf "HTML..."; $MINIFY_BIN $MINIFY_FLAGS --type=html --match="\.html$" -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true
printf "CSS..." ; $MINIFY_BIN $MINIFY_FLAGS --type=css --match="\.css$" -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true
printf "JSON..."; $MINIFY_BIN $MINIFY_FLAGS --type=json --match="\.json$" -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true
printf "SVG..." ; $MINIFY_BIN $MINIFY_FLAGS --type=svg --match="\.svg$" -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true
echo "Done"
|