build: simplify Makefile targets and add live-reload preview

Rename site_* targets to bare names (install, fetch_stats, build,
preview). Replace the static preview target with a watchmedo-driven
live-reload loop so file changes trigger automatic rebuilds. Make
the output directory creation idempotent (exist_ok=True) and static
copy incremental (dirs_exist_ok=True) so repeated builds don't wipe
output on each run.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Vinta Chen
2026-03-18 18:28:27 +08:00
parent 74bba50785
commit 45391b84e9
2 changed files with 15 additions and 13 deletions
+13 -9
View File
@@ -1,17 +1,21 @@
-include .env
export
site_install:
uv sync --no-dev
install:
uv sync
site_fetch_stats:
fetch_stats:
uv run python website/fetch_github_stars.py
site_build:
build:
uv run python website/build.py
site_preview: site_build
python -m http.server -d website/output/ 8000
site_deploy: site_build
@echo "Deploy via GitHub Actions (push to master)"
preview: build
@echo "Check the website on http://localhost:8000"
uv run watchmedo shell-command \
--patterns='*.md;*.html;*.css;*.js;*.py' \
--recursive \
--wait --drop \
--command='uv run python website/build.py' \
README.md website/templates website/static website/data & \
python -m http.server -b 127.0.0.1 -d website/output/ 8000