From 149b8ddc1b4c94e5171c3594e20438d326a06424 Mon Sep 17 00:00:00 2001 From: Zach Butler Date: Fri, 5 Jul 2024 20:37:17 -0400 Subject: [PATCH 1/2] Sort "scripts" field of package.json --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 4745eb3..3c9634e 100644 --- a/package.json +++ b/package.json @@ -3,11 +3,11 @@ "version": "0.0.1", "private": true, "scripts": { - "dev": "vite dev", "build": "vite build", - "preview": "vite preview", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", - "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch" + "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", + "dev": "vite dev", + "preview": "vite preview" }, "devDependencies": { "@sveltejs/adapter-auto": "^3.0.0", From 6a0461d07d8ba584cd4ceb408170d94a4f9228f4 Mon Sep 17 00:00:00 2001 From: Zach Butler Date: Fri, 5 Jul 2024 21:06:54 -0400 Subject: [PATCH 2/2] Write "yarn serve" script to serve static site files using Caddy, the behavior of which is unambiguous --- caddyfile | 9 +++++++++ package.json | 3 ++- serve.sh | 12 ++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 caddyfile create mode 100755 serve.sh diff --git a/caddyfile b/caddyfile new file mode 100644 index 0000000..c07349f --- /dev/null +++ b/caddyfile @@ -0,0 +1,9 @@ +:8443 { + root * ./build + file_server + encode gzip + + tls internal { + on_demand + } +} diff --git a/package.json b/package.json index 3c9634e..78025b3 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "dev": "vite dev", - "preview": "vite preview" + "preview": "vite preview", + "serve": "./serve.sh" }, "devDependencies": { "@sveltejs/adapter-auto": "^3.0.0", diff --git a/serve.sh b/serve.sh new file mode 100755 index 0000000..3af359b --- /dev/null +++ b/serve.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -eo pipefail +function ee { + printf "\e[2m$ %s\e[0m\n" "$*" + eval "$@" +} + +echo 'Starting local Caddy web server.' +echo -e '\e[1;35mURL: https://localhost:8443\e[0m' +echo -e '\e[1;93mPress [Ctrl] + C to exit...\e[0m' + +ee "docker run -v \"\$(git rev-parse --show-toplevel):/http\" -w '/http' -p '8443:8443' caddy caddy run --config caddyfile"