-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·21 lines (16 loc) · 948 Bytes
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
rm -f ../export/index.html
cd script_files
npx esbuild index.js --bundle --minify --outfile=../src/meta/crumblingcastle.js --global-name=crumblingcastle
# make crumblingcastle globally accessible
# from https://stackoverflow.com/questions/64806255/how-to-expose-a-class-to-the-global-scope-with-esbuild
echo "window.crumblingcastle = crumblingcastle;" >> ../src/meta/crumblingcastle.js
cd ../src
npx ifc -o ../export/index.html
# insert contents of addToHead.html into head of export/index.html, before line containing "<title>"
# from https://unix.stackexchange.com/a/32912
cd ..
sed -n -i -e '/<title>/r addToHead.html' -e 1x -e '2,${x;p}' -e '${x;p}' export/index.html
# minify resulting html file with https://www.npmjs.com/package/html-minifier
html-minifier --remove-comments --minify-css true --case-sensitive --sort-attributes --sort-class-name export/index.html > temp.html
mv temp.html export/index.html
echo "Build done (for real)."