Skip to content

Commit

Permalink
bezel: ./serve.sh now runs both a http server and tailwindcss
Browse files Browse the repository at this point in the history
  • Loading branch information
mac-cain13 committed May 13, 2024
1 parent 250f8f6 commit 7399900
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
4 changes: 1 addition & 3 deletions bezel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ Run `./setup-arm64.sh` (or the x64 variant if you're on Intel) to install Tailwi

## Development

Run tailwind locally with `./tailwindcss -i Styles/input.css -o Output/styles.css --watch` from the project folder.

Run the website locally with `./serve.sh` from the project folder, the website will be available at `http://localhost:8000`.
Run `./serve.sh` from the project folder, this will run a http server and Tailwind making the website will be available at `http://localhost:8000`.

If you make changes you can just run the package either from Xcode with the run button or from the commandline with `swift run`. This will build a fresh version of the site that will be served by the above script.

Expand Down
30 changes: 28 additions & 2 deletions bezel/serve.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
#!/bin/bash

# Build the project if needed
[ ! -d "Output" ] && ./build.sh

# Enable us to be able to serve this directory under the path /bezel
SERVE_DIR=`mktemp -d`
ln -s "$(realpath Output)" $SERVE_DIR/bezel
python3 -m http.server --directory $SERVE_DIR 8000
rm -rf $SERVE_DIR

# Start python HTTP server in background
python3 -m http.server --directory $SERVE_DIR 8000 &
PID1=$!
echo "Python server running with PID: $PID1"

# Start Tailwind CSS process in background
./tailwindcss -i Styles/input.css -o Output/styles.css --watch=always &
PID2=$!
echo "Tailwind running with PID: $PID2"

# Function to handle script termination
cleanup() {
echo "Stopping all processes..."
kill $PID1 $PID2
rm -rf "$SERVE_DIR"
echo "Cleanup complete and processes stopped."
}

# Trap SIGINT and exit signals
trap cleanup INT TERM

# Wait for both processes to finish
wait $PID1 $PID2

0 comments on commit 7399900

Please sign in to comment.