|
@@ -2,22 +2,8 @@
|
2
|
2
|
|
3
|
3
|
set -uxeo pipefail
|
4
|
4
|
|
5
|
|
-# Compress all the CSS files together
|
6
|
|
-cat /tmp/site/res/css/*.css > "/tmp/css-concatted.css"
|
7
|
|
-yui-compressor "/tmp/css-concatted.css" > "/tmp/css-combined.css"
|
8
|
|
-
|
9
|
|
-# Generate a small hash to bust caches if the file changes
|
10
|
|
-HASH=`sha256sum /tmp/css-combined.css | cut -c -10`
|
11
|
|
-
|
12
|
|
-# Replace the old CSS with the new
|
13
|
|
-mv "/tmp/css-combined.css" "/tmp/site/res/stylesheet-$HASH.css"
|
14
|
|
-rm -rf "/tmp/site/res/css"
|
15
|
|
-
|
16
|
|
-# Replace the references in the HTML, then run tidy over it
|
|
5
|
+# Run tidy over all HTML
|
17
|
6
|
for file in $(find /tmp/site/ -name '*.html'); do
|
18
|
|
- sed -i "s#\"/res/css/style.css\"#\"/res/stylesheet-$HASH.css\"#g" "$file"
|
19
|
|
- sed -i '\#"/res/css/.*.css"#d' "$file"
|
20
|
|
-
|
21
|
7
|
# Tidy exits if there are warnings, which there probably will be...
|
22
|
8
|
tidy -q -i -w 120 -m --vertical-space yes --drop-empty-elements no "$file" || true
|
23
|
9
|
done
|
|
@@ -25,4 +11,4 @@ done
|
25
|
11
|
# Convert all images to WebP
|
26
|
12
|
for file in $(find /tmp/site -name '*.jpg' -o -name '*.png' -o -name '*.jpeg'); do
|
27
|
13
|
cwebp -m 6 -mt -o "$file.webp" -- "$file"
|
28
|
|
-done
|
|
14
|
+done
|