dnote/web/scripts/dev.sh
2019-08-13 12:54:06 +10:00

39 lines
869 B
Bash
Executable file

#!/usr/bin/env bash
# shellcheck disable=SC1090
# dev.sh builds and starts development environment for standalone app
set -eux -o pipefail
# clean up background processes
function cleanup {
kill "$devServerPID"
}
trap cleanup EXIT
basePath="$GOPATH/src/github.com/dnote/dnote"
appPath="$basePath/web"
serverPath="$basePath/pkg/server"
# load env
set -a
dotenvPath="$serverPath/.env.dev"
source "$dotenvPath"
set +a
# run webpack-dev-server for js in the background
(
cd "$appPath" &&
BASE_URL=http://localhost:8080 \
ASSET_BASE_URL=http://localhost:3000 \
COMPILED_PATH="$appPath"/compiled \
PUBLIC_PATH="$appPath"/public \
STANDALONE=true \
COMPILED_PATH="$basePath/web/compiled" \
IS_TEST=true \
"$appPath"/scripts/webpack-dev.sh
) &
devServerPID=$!
# run server
(cd "$serverPath" && CompileDaemon \
-command="$serverPath/server start")