7 Commits
14 changed files with 116 additions and 97 deletions

No files matched your search

+1 -1
View File
@@ -2,7 +2,7 @@
Copier template for a SvelteKit frontend, either as a `frontend/` part next to other parts or alone at the root of the project (`layout`): SvelteKit on Bun with Tailwind v4, ultracite (biome) and optional shadcn-svelte, served by a Bun server with SSR, as a static SPA behind `serve.ts`, or as a static SPA that the backend api serves from `frontend/build`.
Ships `frontend/docker-compose.yml` with root-relative paths, `docker-compose.local.yml` (published ports) and `docker-compose.prod.yml` (the `caddy` network), a `Makefile` with `fmt`, `check`, `build` and `dev`, `.env.example`, `CLAUDE.md`, `.claude/rules` for Svelte and ultracite, the Svelte MCP server and `.impeccable/` scaffolding. Applied on top of the `infra` template, `layout: parts` or `layout: single` respectively.
Ships `frontend/docker-compose.yml` with root-relative paths and profiles per service, `docker-compose.override.yml.example` (the `caddy` network aliases, copied by `make env`), a `Makefile` with `fmt`, `check`, `build` and `dev`, `.env.example`, `CLAUDE.md`, `.claude/rules` for Svelte and ultracite. The Svelte MCP server comes from `infra`. Applied on top of the `infra` template, `layout: parts` or `layout: single` respectively.
```sh
copier copy --trust -d project_name="My Thing" -d serve=bun <this-repo> <dest>
-5
View File
@@ -37,11 +37,6 @@ ui_library:
shadcn-svelte: shadcn
default: none
include_impeccable:
type: bool
help: .impeccable/ scaffolding for the impeccable skill
default: true
install_deps:
type: bool
help: bun install after generation
-8
View File
@@ -1,8 +0,0 @@
{
"mcpServers": {
"svelte": {
"type": "http",
"url": "https://mcp.svelte.dev/mcp"
}
}
}
@@ -1,3 +0,0 @@
config.local.json
hook.cache.json
hook.pending.json
+3 -1
View File
@@ -1,2 +1,4 @@
{% if layout == 'root' %}COMPOSE_FILE=docker-compose.yml:docker-compose.local.yml
{% if layout == 'root' %}COMPOSE_PROFILES=services
{% endif %}PUBLIC_API_BASE_URL=/api
ALLOWED_HOSTS=
+34 -15
View File
@@ -1,8 +1,9 @@
COMPOSE := docker compose{% if layout == 'part' %} --project-directory ..{% endif %}
{% if layout == 'root' %}SERVICES := $(COMPOSE) --profile services
EXTERNAL := $(COMPOSE) --profile external
{% endif %}
.PHONY: {% if layout == 'root' %}env external recreate rebuild restart logs down {% endif %}fmt check build dev
COMPOSE := {% if layout == 'part' %}cd .. && {% endif %}docker compose
{% if serve != 'api' %}IMAGE := {{ project_slug }}/frontend
{% endif %}changed = ! git diff --quiet $(1) -- $(2) 2>/dev/null
stamp = { git update-ref $(1) HEAD 2>/dev/null || true; }
.PHONY: {% if layout == 'root' %}env recreate rebuild restart logs down deploy {% endif %}fmt check build pre-deploy post-deploy dev
fmt:
bun run fix
@@ -15,26 +16,44 @@ build:
{% if serve == 'api' %} $(COMPOSE) run --rm frontend-dev sh -c "bun install && bun run build"
{% else %} $(COMPOSE) build frontend
{% endif %}
pre-deploy:
@if $(call changed,refs/deploy/frontend,.) || {% if serve == 'api' %}! test -d build{% else %}! docker image inspect $(IMAGE) >/dev/null 2>&1{% endif %}; then \
$(MAKE) build && $(call stamp,refs/deploy/frontend); \
fi
post-deploy:
@:
dev:
bun run dev
{% if layout == 'root' %}
env:
@test -f .env || cp .env.example .env
@fresh=; test -f .env || { cp .env.example .env; fresh=1; }; \
if ! test -f docker-compose.override.yml; then \
cp docker-compose.override.yml.example docker-compose.override.yml; \
for port in $$(sed -n 's/.*127\.0\.0\.1:\([0-9]*\):.*/\1/p' docker-compose.override.yml | sort -u); do \
random=$$((20000 + $$(od -An -N2 -tu2 /dev/urandom) % 40000)); \
sed "s/127\.0\.0\.1:$$port:/127.0.0.1:$$random:/" docker-compose.override.yml > docker-compose.override.yml.tmp && mv docker-compose.override.yml.tmp docker-compose.override.yml; \
test -z "$$fresh" || { sed "s|localhost:$$port/|localhost:$$random/|" .env > .env.tmp && mv .env.tmp .env; }; \
done; \
fi
external:
$(EXTERNAL) up -d
recreate:
$(COMPOSE) up -d --force-recreate
recreate: external
$(SERVICES) up -d --force-recreate
rebuild: build recreate
rebuild: build
$(COMPOSE) up -d
restart:
$(SERVICES) restart
$(COMPOSE) restart
logs:
$(SERVICES) logs -f --tail=100
$(COMPOSE) logs -f --tail=100
down:
$(EXTERNAL) --profile services down
$(COMPOSE) down
deploy: pre-deploy
$(COMPOSE) up -d
$(MAKE) post-deploy
{% endif %}
+1 -7
View File
@@ -2,13 +2,7 @@
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"extends": ["ultracite/biome/core", "ultracite/biome/svelte"],
"files": {
"includes": [
"!.claude",
"!.svelte-kit",
"!build",
"!.mcp.json",
"!.impeccable"
]
"includes": ["!.claude", "!.svelte-kit", "!build", "!.mcp.json"]
},
"javascript": { "globals": ["Bun"] },
"overrides": [
@@ -1,8 +0,0 @@
services:
{% if serve != 'api' %} frontend:
ports:
- "127.0.0.1:3000:3000"
{% endif %} frontend-dev:
ports:
- "127.0.0.1:3000:3000"
@@ -0,0 +1,23 @@
{%- set dash = project_slug | replace('_', '-') -%}
services:
{% if serve != 'api' %} frontend:
networks:
default: {}
caddy:
aliases:
- {{ dash }}-frontend
# ports:
# - "127.0.0.1:3000:3000"
{% endif %} frontend-dev:
networks:
default: {}
caddy:
aliases:
- {{ dash }}-frontend
# ports:
# - "127.0.0.1:3000:3000"
networks:
caddy:
external: true
@@ -1,15 +0,0 @@
{%- set dash = project_slug | replace('_', '-') -%}
{% if serve != 'api' -%}
services:
frontend:
networks:
caddy:
aliases:
- {{ dash }}-frontend
networks:
caddy:
external: true
{%- else -%}
services: {}
{%- endif %}
+35 -29
View File
@@ -1,41 +1,47 @@
{
"name": "{{ project_slug }}",
"type": "module",
"private": true,
"version": "0.0.1",
"private": true,
"type": "module",
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"prepare": "svelte-kit sync || echo ''",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"dev": "vite dev",
"fix": "ultracite fix",
"lint": "ultracite check",
"fix": "ultracite fix"
"prepare": "svelte-kit sync || echo ''",
"preview": "vite preview"
},
"devDependencies": {
"@biomejs/biome": "2.5.2",
"@sveltejs/kit": "^2.63.0",
"@sveltejs/vite-plugin-svelte": "^7.1.2",
"@tailwindcss/vite": "^4.3.0",
"@types/bun": "^1.3.0",
{% if frontend_adapter == 'bun' %} "svelte-adapter-bun": "^1.0.1",
{% else %} "@sveltejs/adapter-static": "^3.0.10",
{% endif %}{% if ui_library == 'shadcn' %} "@internationalized/date": "^3.12.0",
"@lucide/svelte": "^1.23.0",
"bits-ui": "^2.16.3",
"clsx": "^2.1.1",
"mode-watcher": "^1.1.0",
"shadcn-svelte": "^1.3.0",
"svelte-sonner": "^1.1.0",
"tailwind-merge": "^3.5.0",
"tailwind-variants": "^3.2.2",
"tw-animate-css": "^1.4.0",
{% endif %} "svelte": "^5.56.1",
"svelte-check": "^4.6.0",
"tailwindcss": "^4.3.0",
"typescript": "^6.0.3",
"ultracite": "7.9.0",
"vite": "^8.0.16"
{%- set deps = {
"@biomejs/biome": "2.5.13",
"@sveltejs/kit": "^2.63.0",
"@sveltejs/vite-plugin-svelte": "^7.1.2",
"@tailwindcss/vite": "^4.3.0",
"@types/bun": "^1.3.0",
"svelte": "^5.56.1",
"svelte-check": "^4.6.0",
"tailwindcss": "^4.3.0",
"typescript": "^6.0.3",
"ultracite": "7.12.0",
"vite": "^8.0.16",
} -%}
{%- if frontend_adapter == 'bun' %}{% set _ = deps.update({"svelte-adapter-bun": "^1.0.1"}) %}{% else %}{% set _ = deps.update({"@sveltejs/adapter-static": "^3.0.10"}) %}{% endif -%}
{%- if ui_library == 'shadcn' %}{% set _ = deps.update({
"@internationalized/date": "^3.12.0",
"@lucide/svelte": "^1.23.0",
"bits-ui": "^2.16.3",
"clsx": "^2.1.1",
"mode-watcher": "^1.1.0",
"shadcn-svelte": "^1.3.0",
"svelte-sonner": "^1.1.0",
"tailwind-merge": "^3.5.0",
"tailwind-variants": "^3.2.2",
"tw-animate-css": "^1.4.0",
}) %}{% endif %}
{%- for name, version in deps | dictsort %}
"{{ name }}": "{{ version }}"{{ "," if not loop.last }}
{%- endfor %}
}
}
+5
View File
@@ -2,9 +2,14 @@ import { sveltekit } from "@sveltejs/kit/vite";
import tailwindcss from "@tailwindcss/vite";
import { defineConfig } from "vite";
const allowedHosts = process.env.ALLOWED_HOSTS
? process.env.ALLOWED_HOSTS.split(",")
: undefined;
export default defineConfig({
plugins: [tailwindcss(), sveltekit()],
server: {
allowedHosts,
proxy: {
"/api": {
changeOrigin: true,
@@ -16,8 +16,3 @@ node_modules
# Vite
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
# Impeccable
**/.impeccable/config.local.json
**/.impeccable/hook.cache.json
**/.impeccable/hook.pending.json
@@ -0,0 +1,14 @@
# {{ project_name }}
Runs in Docker, locally the same way as in production. `COMPOSE_PROFILES` in `.env` selects the services that run on this machine. `docker-compose.override.yml` holds what differs between machines: published ports and the aliases on the external `caddy` network.
```sh
make env
make recreate
```
`make env` creates `.env` and `docker-compose.override.yml` from their examples. `make recreate` starts the selected profiles, `make rebuild` builds the image first, `make logs`, `make restart` and `make down` do what they say.
To deploy, `git pull && make deploy`. It runs `make pre-deploy`, which rebuilds the image only when something in the repository changed, then `docker compose up -d`. A deploy system with its own `up` step calls `make pre-deploy` before it and `make post-deploy` after. What was built is remembered as `refs/deploy/*` in the clone.
`make dev` runs the Vite dev server on the host, `make fmt` formats, `make check` runs svelte-check and the linter.