diff --git a/.gitignore b/.gitignore index 15f2f39..d6c0c56 100644 --- a/.gitignore +++ b/.gitignore @@ -5,8 +5,7 @@ node_modules out dist *.tgz -static/tailwind.css -static/*.js +dist/ # code coverage coverage diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2ee9c2f..c9df9e1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -30,8 +30,8 @@ go test ./... go run ./cmd/server ``` -TypeScript source files live in `static/*.ts` and are bundled to matching `static/*.js` files for runtime. -Generated `static/*.js` and `static/tailwind.css` files are ignored by git. +TypeScript source files live in `static/*.ts` and are bundled to runtime assets in `dist/`. +Generated `dist/` files are ignored by git. ## Development guidelines diff --git a/Dockerfile b/Dockerfile index 5eb40b0..5943dbd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,6 +42,7 @@ RUN mkdir -p /app/data COPY --from=builder /app/main_server . COPY --from=builder /app/static ./static +COPY --from=builder /app/dist ./dist COPY --from=builder /app/migrations ./migrations # Expose the application port diff --git a/README.md b/README.md index 89d5b4d..4361125 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ bun run build:assets go run ./cmd/server ``` -The frontend pipeline uses a single source stylesheet (`static/style.css`) and TypeScript sources in `static/*.ts`, then emits build artifacts (`static/tailwind.css` and `static/*.js`) for serving. +The frontend pipeline uses a single source stylesheet (`static/style.css`) and TypeScript sources in `static/*.ts`, then emits build artifacts into `dist/` (`dist/tailwind.css` and `dist/*.js`) for serving. When the server starts, the app is available at `http://localhost:3000`. diff --git a/internal/server/routes.go b/internal/server/routes.go index 8fd9b00..d3fafe2 100644 --- a/internal/server/routes.go +++ b/internal/server/routes.go @@ -32,6 +32,10 @@ func NewRouter(cfg Config) http.Handler { fs := http.FileServer(http.Dir("./static")) mux.Handle("/static/", http.StripPrefix("/static/", fs)) + // Serve built frontend assets + dist := http.FileServer(http.Dir("./dist")) + mux.Handle("/dist/", http.StripPrefix("/dist/", dist)) + mux.HandleFunc("/", animeHandler.HandleCatalog) mux.HandleFunc("/discover", animeHandler.HandleDiscover) mux.HandleFunc("/notifications", animeHandler.HandleNotifications) diff --git a/internal/templates/layout.templ b/internal/templates/layout.templ index abb21cc..592fe4c 100644 --- a/internal/templates/layout.templ +++ b/internal/templates/layout.templ @@ -10,12 +10,12 @@ templ Layout(title string, showHeader bool) { { title } - + - - - - + + + + if showHeader { @@ -48,7 +48,7 @@ templ Layout(title string, showHeader bool) { }> { children... } - + } diff --git a/package.json b/package.json index 1ee4103..51441ee 100644 --- a/package.json +++ b/package.json @@ -2,9 +2,9 @@ "name": "myanimelist-ui", "private": true, "scripts": { - "build:css": "bunx @tailwindcss/cli -i ./static/style.css -o ./static/tailwind.css", - "watch:css": "bunx @tailwindcss/cli -i ./static/style.css -o ./static/tailwind.css --watch", - "build:ts": "bun build ./static/*.ts --outdir ./static --target browser", + "build:css": "bunx @tailwindcss/cli -i ./static/style.css -o ./dist/tailwind.css", + "watch:css": "bunx @tailwindcss/cli -i ./static/style.css -o ./dist/tailwind.css --watch", + "build:ts": "bun build ./static/*.ts --outdir ./dist --target browser", "typecheck": "bunx tsc -p tsconfig.json --noEmit", "build:assets": "bun run build:css && bun run build:ts" },