-
Notifications
You must be signed in to change notification settings - Fork 13.3k
/
Copy pathreduce_index.sh
executable file
·56 lines (47 loc) · 1.12 KB
/
reduce_index.sh
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
#/bin/sh
# Processing script to optionally reduce filesystem use by miniying, gzipping and preparing index.htm for embedding in code.
# Please see readme.md for more information.
# Requires xdd which is part of the VIM package
# Requires npm
# sudo apt install npm
# ln -s /usr/bin/nodejs /usr/bin/node
# Requires html-minifier
# sudo npm install html-minifier -g
html-minifier \
--case-sensitive \
--collapse-boolean-attributes \
--collapse-whitespace \
--minify-css true \
--minify-js true \
--process-conditional-comments \
--remove-attribute-quotes \
--remove-comments \
--remove-empty-attributes \
--remove-optional-tags \
--remove-redundant-attributes \
--remove-script-type-attributes \
--remove-style-link-type-attributes \
-o index.htm \
../data/edit/index.htm
if [ $? -ne 0 ]
then
echo "Error minifying index.htm"
exit -1
fi
if [ -e index.htm.gz ]
then
rm index.htm.gz
fi
gzip index.htm
if [ $? -ne 0 ]
then
echo "Error gzipping minified index.htm"
exit -1
fi
xxd -i index.htm.gz > index_htm.h
if [ $? -ne 0 ]
then
echo "Error creating include file for index.htm"
exit -1
fi
echo Reduce complete.