-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathbuild.sh
executable file
·42 lines (36 loc) · 889 Bytes
/
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
#!/bin/bash
# Vendor libs
(
echo "vendoring..."
cd scripts || exit
cat dayjs-duration-utc.js draggabilly.pkgd.min.js typed.js powerglitch.min.js > vendor.js
)
VENDOR_JS=$(cat scripts/vendor.js)
export VENDOR_JS
SCRIPT_JS=$(cat scripts/script.js)
export SCRIPT_JS
envsubst < index.pre.html > index.html
rm -rf dist/
rsync --exclude=index.pre.html \
--exclude=*.sh \
--exclude=dist/ \
--exclude=.git* \
--exclude=.prettierignore \
--exclude=LICENSE \
--exclude=README.md \
--delete -av . dist/
echo "run prettier"
prettier -w .
cpu_cores="$(nproc)"
echo "Minifying everything we can"
find ./dist/ -type f \( \
-name "*.html" \
-o -name '*.js' \
-o -name '*.css' \
-o -name '*.svg' \
-o -name "*.xml" \
-o -name "*.json" \
-o -name "*.html" \
\) \
-and ! -name "*.min*" -print0 |
xargs -0 -n1 -P"${cpu_cores}" -I '{}' sh -c 'minify -o "{}" "{}"'