diff --git a/serve b/serve index 8b35a1a..b510ca1 100755 --- a/serve +++ b/serve @@ -15,6 +15,16 @@ SCSS_PATH="$WEBROOT/scss" CSS_PATH="$WEBROOT/css" # ========================= # +# ===== Local State ===== # +SASS_PID= +# ======================= # + +function cleanup { + if [[ -n "$SASS_PID" ]]; then + kill "$SASS_PID" + fi +} + # Watch .sass/.scss files and compile on change function watch_scss { # watch format "SCSS_PATH:OUT_PATH" @@ -37,8 +47,13 @@ function host { simple-http-server $args $@ -- "$WEBROOT" } +trap cleanup EXIT set -ueo pipefail set -x +# auto compile scss changes watch_scss & -hostwww +SASS_PID=$! + +# host dev server +host ${SRV_ARGS[@]}