Files
2026-04-24 14:03:17 +02:00

40 lines
1013 B
Bash
Executable File

#!/usr/bin/env bash
set -eo pipefail # this can be harmful, see https://www.youtube.com/watch?v=4Jo3Ml53kvc
. bs/.common || {
echo 'Please run this script from the project root directory' >&2;
exit 1;
}
# "start:build": "web-dev-server --root-dir dist --app-index index.html --open",
# "start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"web-dev-server\""
# depends on
declare -r server='node_modules/.bin/web-dev-server'
declare -r lint='bs/lint'
declare -r index='index.html'
help(){
if ! isHelp "${@}"; then return 0; fi
echoReadmeInfo
cat <<-EOF
Options:
./src Starts the development server (default)
./dist Starts the production server
EOF
$server --help
exit 0
}
main(){
help "${@}"
local -r target="${1:-./src}" # ./src or ./dist
if [[ "$target" == './dist' ]]; then
# console warns because of config file, use npx serve?
$server --root-dir "$target" --app-index $index --open
else
$lint --watch --preserveWatchOutput &
$server &
wait
fi
}
main "${@}"