diff options
| -rwxr-xr-x | scripts/_build-and-serve.sh | 6 | ||||
| -rwxr-xr-x | scripts/build-prod.sh | 19 | ||||
| -rwxr-xr-x | scripts/debug.sh | 9 |
3 files changed, 34 insertions, 0 deletions
diff --git a/scripts/_build-and-serve.sh b/scripts/_build-and-serve.sh new file mode 100755 index 0000000..7e98061 --- /dev/null +++ b/scripts/_build-and-serve.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +PORT=${1} + +mkdir -p build && rm -r build/* +elm make src/Main.elm --debug --output build/index.html && python3 -m http.server ${PORT} -d build diff --git a/scripts/build-prod.sh b/scripts/build-prod.sh new file mode 100755 index 0000000..7f73a6f --- /dev/null +++ b/scripts/build-prod.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +TOP_LEVEL="$(git rev-parse --show-toplevel)" +OUT_FILE="build/index.js" +OUT_MIN_FILE="build/index.min.js" + +mkdir -p build && rm -r build/* + +echo ":: Outputting JS to ${OUT_FILE}" +echo ":: Outputting optimized JS to ${OUT_MIN_FILE}" +echo ":: Outputting index.html to build/index.html" + +elm make src/Main.elm --optimize --output="${OUT_FILE}" +uglifyjs "${OUT_FILE}" --compress 'pure_funcs=[F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9],pure_getters,keep_fargs=false,unsafe_comps,unsafe' | uglifyjs --mangle --output "${OUT_MIN_FILE}" +cp index.prod.html build/index.html + +echo ":: Compiled size: $(wc -c $OUT_FILE) bytes ($OUT_FILE)" +echo ":: Minified size: $(wc -c $OUT_MIN_FILE) bytes ($OUT_MIN_FILE)" +echo ":: Gzipped size: $(gzip -c $OUT_MIN_FILE | wc -c) bytes" diff --git a/scripts/debug.sh b/scripts/debug.sh new file mode 100755 index 0000000..0ae14a3 --- /dev/null +++ b/scripts/debug.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +TOP_LEVEL="$(git rev-parse --show-toplevel)" +PORT="${1:-8001}" + +echo ":: Watching directory src/ and serving continuous builds on http://localhost:${PORT}" + +bash scripts/_build-and-serve.sh ${PORT} +fswatch -or src | xargs -n1 -I{} bash scripts/_build-and-serve.sh ${PORT} |
