feat!: sveltekit 3 with the official bun adapter, config lives in vite.config; biome unpinned at 2.5.15, anchor content check off for svelte; bun image pinned to the 1 tag

This commit is contained in:
hh committed 2026-10-10 22:39:07 +00:00
1 parent 5cee5f99e9
commit 6c9d5063b9
11 files changed
+89 -85

No files matched your search

+10 -6
View File
@@ -3,6 +3,10 @@
"version": "0.0.1", "version": "0.0.1",
"private": true, "private": true,
"type": "module", "type": "module",
"imports": {
"#lib": "./src/lib/index.js",
"#lib/*": "./src/lib/*"
},
"scripts": { "scripts": {
"build": "vite build", "build": "vite build",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
@@ -20,19 +24,19 @@
}, },
"devDependencies": { "devDependencies": {
{%- set deps = { {%- set deps = {
"@sveltejs/kit": "^2.63.0", "@sveltejs/kit": "^3.0.1",
"@sveltejs/vite-plugin-svelte": "^7.1.2", "@sveltejs/vite-plugin-svelte": "^7.1.2",
"@tailwindcss/vite": "^4.3.0", "@tailwindcss/vite": "^4.3.0",
"@types/bun": "^1.3.0", "@types/bun": "^1.3.0",
"svelte": "^5.56.1", "svelte": "^5.57.1",
"svelte-check": "^4.6.0", "svelte-check": "^4.7.6",
"tailwindcss": "^4.3.0", "tailwindcss": "^4.3.0",
"typescript": "^6.0.3", "typescript": "^6.0.3",
"vite": "^8.0.16", "vite": "^8.0.16",
} -%} } -%}
{%- if linter == 'biome' %}{% set _ = deps.update({ {%- if linter == 'biome' %}{% set _ = deps.update({
"@biomejs/biome": "2.5.13", "@biomejs/biome": "^2.5.15",
"ultracite": "7.12.0", "ultracite": "^7.12.4",
}) %}{% else %}{% set _ = deps.update({ }) %}{% else %}{% set _ = deps.update({
"@eslint/compat": "^2.1.1", "@eslint/compat": "^2.1.1",
"@eslint/js": "^10.0.1", "@eslint/js": "^10.0.1",
@@ -45,7 +49,7 @@
"prettier-plugin-tailwindcss": "^0.8.1", "prettier-plugin-tailwindcss": "^0.8.1",
"typescript-eslint": "^8.71.1", "typescript-eslint": "^8.71.1",
}) %}{% endif -%} }) %}{% endif -%}
{%- 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 frontend_adapter == 'bun' %}{% set _ = deps.update({"@sveltejs/adapter-bun": "^1.0.0"}) %}{% else %}{% set _ = deps.update({"@sveltejs/adapter-static": "^4.0.0"}) %}{% endif -%}
{%- if ui_library == 'shadcn' %}{% set _ = deps.update({ {%- if ui_library == 'shadcn' %}{% set _ = deps.update({
"@internationalized/date": "^3.12.0", "@internationalized/date": "^3.12.0",
"@lucide/svelte": "^1.23.0", "@lucide/svelte": "^1.23.0",
+5
View File
@@ -0,0 +1,5 @@
import { defineEnvVars } from "@sveltejs/kit/env";
export const variables = defineEnvVars({
PUBLIC_API_BASE_URL: { public: true, schema: (input) => input ?? "/api" },
});
@@ -1,6 +1,6 @@
import { env } from "$env/dynamic/public"; import { PUBLIC_API_BASE_URL } from "$app/env/public";
const BASE = env.PUBLIC_API_BASE_URL ?? "/api"; const BASE = PUBLIC_API_BASE_URL;
export class ApiError extends Error { export class ApiError extends Error {
status: number; status: number;
@@ -1,3 +1,3 @@
// place files you want to import through the `$lib` alias in this folder. // place files you want to import through the `#lib` alias in this folder.
{% if linter == 'biome' %}// biome-ignore-all lint/suspicious/noEmptySource: temporary {% if linter == 'biome' %}// biome-ignore-all lint/suspicious/noEmptySource: temporary
{% endif %} {% endif %}
@@ -1,36 +0,0 @@
{% if frontend_adapter == 'bun' -%}
import adapter from "svelte-adapter-bun";
/** @type {import('@sveltejs/kit').Config} */
const config = {
compilerOptions: {
runes: ({ filename }) =>
{% if linter == 'biome' %} // biome-ignore lint/performance/useTopLevelRegex: svelte default behaviour
{% endif %} filename.split(/[/\\]/).includes("node_modules") ? undefined : true,
},
kit: {
adapter: adapter(),
},
};
export default config;
{%- else -%}
import adapter from "@sveltejs/adapter-static";
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
adapter: adapter({
assets: "build",
fallback: "index.html",
pages: "build",
precompress: false,
strict: false,
}),
},
preprocess: vitePreprocess(),
};
export default config;
{%- endif %}
+4 -15
View File
@@ -1,20 +1,9 @@
{ {
"extends": "./.svelte-kit/tsconfig.json", "extends": "$app/tsconfig",
"compilerOptions": { "compilerOptions": {
"rewriteRelativeImportExtensions": true, "rewriteRelativeImportExtensions": true,
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true, "sourceMap": true,
"strict": true, "strict": true
"moduleResolution": "bundler" },
} "include": ["src", "vite.config.ts"]
// Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
// except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
//
// To make changes to top-level options such as include and exclude, we recommend extending
// the generated config; see https://svelte.dev/docs/kit/configuration#typescript
} }
-20
View File
@@ -1,20 +0,0 @@
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,
target: process.env.API_PROXY_TARGET ?? "http://localhost:8080",
},
},
},
});
@@ -0,0 +1,51 @@
{% if frontend_adapter == 'bun' -%}
import adapter from "@sveltejs/adapter-bun";
import { sveltekit } from "@sveltejs/kit/vite";
import tailwindcss from "@tailwindcss/vite";
import { defineConfig } from "vite";
const PATH_SEP = /[/\\]/;
{%- else -%}
import adapter from "@sveltejs/adapter-static";
import { sveltekit } from "@sveltejs/kit/vite";
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
import tailwindcss from "@tailwindcss/vite";
import { defineConfig } from "vite";
{%- endif %}
const allowedHosts = process.env.ALLOWED_HOSTS
? process.env.ALLOWED_HOSTS.split(",")
: undefined;
export default defineConfig({
plugins: [
tailwindcss(),
sveltekit({
{%- if frontend_adapter == 'bun' %}
adapter: adapter(),
compilerOptions: {
runes: ({ filename }) =>
filename.split(PATH_SEP).includes("node_modules") ? undefined : true,
},
{%- else %}
adapter: adapter({
assets: "build",
fallback: "index.html",
pages: "build",
precompress: false,
strict: false,
}),
preprocess: [vitePreprocess()],
{%- endif %}
}),
],
server: {
allowedHosts,
proxy: {
"/api": {
changeOrigin: true,
target: process.env.API_PROXY_TARGET ?? "http://localhost:8080",
},
},
},
});
@@ -21,6 +21,7 @@
"includes": ["**/*.svelte"], "includes": ["**/*.svelte"],
"linter": { "linter": {
"rules": { "rules": {
"a11y": { "useAnchorContent": "off" },
"style": { "style": {
"useFilenamingConvention": { "useFilenamingConvention": {
"level": "error", "level": "error",
@@ -6,10 +6,20 @@ import svelte from "eslint-plugin-svelte";
import { defineConfig } from "eslint/config"; import { defineConfig } from "eslint/config";
import globals from "globals"; import globals from "globals";
import ts from "typescript-eslint"; import ts from "typescript-eslint";
import svelteConfig from "./svelte.config.js";
const gitignorePath = fileURLToPath(new URL("./.gitignore", import.meta.url)); const gitignorePath = fileURLToPath(new URL("./.gitignore", import.meta.url));
{% if frontend_adapter == 'bun' -%}
const svelteConfig = {
compilerOptions: {
runes: ({ filename }) =>
filename.split(/[/\\]/).includes("node_modules") ? undefined : true,
},
};
{%- else -%}
const svelteConfig = {};
{%- endif %}
export default defineConfig( export default defineConfig(
includeIgnoreFile(gitignorePath), includeIgnoreFile(gitignorePath),
js.configs.recommended, js.configs.recommended,
@@ -1,5 +1,5 @@
{% if frontend_adapter == 'bun' -%} {% if frontend_adapter == 'bun' -%}
FROM oven/bun:alpine AS deps FROM oven/bun:1-alpine AS deps
ENV TERM=xterm-256color ENV TERM=xterm-256color
ENV COLORTERM=truecolor ENV COLORTERM=truecolor
@@ -22,7 +22,7 @@ RUN bun --bun svelte-kit sync
RUN bun --bun run build RUN bun --bun run build
FROM oven/bun:alpine AS runtime FROM oven/bun:1-alpine AS runtime
ENV NODE_ENV=production ENV NODE_ENV=production
# The cache mount only holds files; without the variable bun caches into # The cache mount only holds files; without the variable bun caches into
@@ -42,7 +42,7 @@ EXPOSE 3000
ENTRYPOINT ["bun"] ENTRYPOINT ["bun"]
CMD ["build/index.js"] CMD ["build/index.js"]
{%- else -%} {%- else -%}
FROM oven/bun:alpine AS deps FROM oven/bun:1-alpine AS deps
ENV TERM=xterm-256color ENV TERM=xterm-256color
ENV COLORTERM=truecolor ENV COLORTERM=truecolor
@@ -63,7 +63,7 @@ RUN bun --bun svelte-kit sync
RUN bun run build RUN bun run build
FROM oven/bun:alpine AS runtime FROM oven/bun:1-alpine AS runtime
ENV NODE_ENV=production ENV NODE_ENV=production