-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbuild.sh
executable file
·83 lines (66 loc) · 2.19 KB
/
build.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
echo "Checking for folders and clearing them..."
rm -r ./assets/css/
mkdir -p ./assets/css/
rm -r ./assets/js/
mkdir -p ./assets/js/
if [ -n $ICONS ]; then
echo "Clearing and remaking icon folder..."
rm -r ./assets/icons/
mkdir -p ./assets/icons/
echo "Exporting icon Inkscape SVG to PNG and plain SVG..."
inkscape \
-y 0 \
--vacuum-defs \
-f assets-src/icons/sprites.svg \
--export-plain-svg assets/icons/sprites.svg \
--export-png assets/icons/sprites.png
else
echo "Skipping icon build section..."
fi
echo "Converting app LESS and compressing output CSS..."
spritedc="$(md5sum assets-src/icons/sprites.svg | cut -c -5)"
cat \
assets-src/css/style.less \
| sed "s/dc=0/dc=${spritedc}/" \
| lessc --clean-css - \
| java -jar bin/yuicompressor-2.4.8.jar --type=css \
> ./assets/css/compiled.css
echo "Converting print LESS and compressing output CSS..."
cat \
assets-src/css/print.less \
| lessc --clean-css - \
| java -jar bin/yuicompressor-2.4.8.jar --type=css \
> ./assets/css/compiled_print.css
echo "Combining and compressing global JS..."
cat \
assets-src/js/jquery-3.2.1.min.js \
assets-src/js/jquery-migrate-3.0.1.min.js \
assets-src/js/global.js \
| java -jar bin/yuicompressor-2.4.8.jar --type=js \
> ./assets/js/global.js
echo "Combining and compressing app JS..."
cat \
assets-src/js/Constants.js \
assets-src/js/TileDeck.js \
assets-src/js/TileLibrary.js \
assets-src/js/Mapper.js \
assets-src/js/GUI.js \
assets-src/js/mapping.js \
| java -jar bin/yuicompressor-2.4.8.jar --type=js \
> ./assets/js/compiled_app.js
echo "Combining and compressing keyboard shortcut JS..."
cat \
assets-src/js/keyboard.js \
| java -jar bin/yuicompressor-2.4.8.jar --type=js \
> ./assets/js/keyboard.js
echo "Updating and compressing service worker JS..."
contentsum="$(tar -cf - content | md5sum | cut -c -10)"
assetssum="$(tar -cf - assets-src | md5sum | cut -c -10)"
indexsum="$(md5sum index.php | cut -c -5)"
cat \
assets-src/js/service-worker.js \
| sed "s/my-site-cache-v1/${contentsum}-${assetssum}-${indexsum}/" \
| java -jar bin/yuicompressor-2.4.8.jar --type=js \
> ./assets/js/service-worker.js
echo "Build complete!"