Skip to content

Commit

Permalink
Minor improvements to build process and startup scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
abhahn committed Jul 26, 2024
1 parent 2cfb4fb commit 5c4c9c5
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 28 deletions.
2 changes: 1 addition & 1 deletion frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default defineConfig({
plugins: [react()],
build: {
outDir: '../static',
emptyOutDir: true,
emptyOutDir: false,
sourcemap: true
},
server: {
Expand Down
14 changes: 14 additions & 0 deletions start.cmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
@echo off
setlocal
REM Sample app startup script

REM Process CLI options
set CMD=%~1
if "%CMD%" == "" (
echo Building the application. To skip this step in the future, use the `--skip-build` option.
goto build
) else if "%CMD%" == "--skip-build" (
echo Skipping build...
goto run
)

:build
set NODE_OPTIONS=--max_old_space_size=8192

echo.
Expand Down Expand Up @@ -30,6 +43,7 @@ if "%errorlevel%" neq "0" (
exit /B %errorlevel%
)

:run
echo.
echo Starting backend
echo.
Expand Down
96 changes: 69 additions & 27 deletions start.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,76 @@
#!/bin/bash
#!/bin/bash -e

# script usage info
function usage() {
cat <<USAGE
Usage: $0 [-s|--skip-build]
Options:
-s, --skip-build: Optional.
USAGE
exit 1
}

function build() {
echo "Building the application. To skip this step in the future, use the `--skip-build` option."
echo ""
echo "Restoring frontend npm packages"
echo ""
cd frontend
npm install
if [ $? -ne 0 ]; then
echo "Failed to restore frontend npm packages"
exit $?
fi

echo ""
echo "Building frontend"
echo ""
npm run build
if [ $? -ne 0 ]; then
echo "Failed to build frontend"
exit $?
fi
cd ..

echo ""
echo "Restoring backend python packages"
. ./scripts/loadenv.sh
}

function run() {
echo ""
echo "Starting backend"
echo ""
./.venv/bin/python -m quart run --port=50505 --host=127.0.0.1 --reload
if [ $? -ne 0 ]; then
echo "Failed to start backend"
exit $?
fi
}

SKIP_BUILD=0
while [ "$1" != "" ]; do
case $1 in
-s | --skip-build)
SKIP_BUILD=1
;;
*)
usage
exit 1
;;
esac
shift
done

export NODE_OPTIONS=--max_old_space_size=8192

echo ""
echo "Restoring frontend npm packages"
echo ""
cd frontend
npm install
if [ $? -ne 0 ]; then
echo "Failed to restore frontend npm packages"
exit $?
if [[ $SKIP_BUILD == 0 ]]; then
build
fi

echo ""
echo "Building frontend"
echo ""
npm run build
if [ $? -ne 0 ]; then
echo "Failed to build frontend"
exit $?
fi
run


cd ..
. ./scripts/loadenv.sh

echo ""
echo "Starting backend"
echo ""
./.venv/bin/python -m quart run --port=50505 --host=127.0.0.1 --reload
if [ $? -ne 0 ]; then
echo "Failed to start backend"
exit $?
fi

0 comments on commit 5c4c9c5

Please sign in to comment.