Skip to content

Commit 3c1ae1d

Browse files
committed
chore(www): use typescript for config files
1 parent 84673d4 commit 3c1ae1d

File tree

7 files changed

+182
-103
lines changed

7 files changed

+182
-103
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ Dockerfile
22
target/
33
node_modules/
44
/www/build
5+
/www/svelte.config.ts

www/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ node_modules
88
/.svelte-kit
99
/build
1010

11+
# Generated
12+
svelte.config.js
13+
1114
# OS
1215
.DS_Store
1316
Thumbs.db

www/bun.lock

Lines changed: 141 additions & 83 deletions
Large diffs are not rendered by default.

www/eslint.config.js renamed to www/eslint.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import prettier from 'eslint-config-prettier';
22
import { includeIgnoreFile } from '@eslint/compat';
3+
import { defineConfig } from 'eslint/config';
34
import js from '@eslint/js';
45
import svelte from 'eslint-plugin-svelte';
56
import globals from 'globals';
@@ -9,7 +10,7 @@ import svelteConfig from './svelte.config.js';
910

1011
const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url));
1112

12-
export default ts.config(
13+
export default defineConfig(
1314
includeIgnoreFile(gitignorePath),
1415
js.configs.recommended,
1516
...ts.configs.recommended,

www/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dev": "vite dev",
88
"build": "vite build",
99
"preview": "vite preview",
10-
"prepare": "svelte-kit sync || echo ''",
10+
"prepare": "COMPILE_JS=true bun run svelte.config.ts && svelte-kit sync || echo ''",
1111
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
1212
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
1313
"format": "prettier --write .",
@@ -20,6 +20,8 @@
2020
"@sveltejs/kit": "^2.37.0",
2121
"@sveltejs/vite-plugin-svelte": "^6.1.4",
2222
"@tailwindcss/vite": "^4.1.12",
23+
"@types/node": "^24.3.0",
24+
"esbuild": "^0.25.9",
2325
"eslint": "^9.34.0",
2426
"eslint-config-prettier": "^10.1.8",
2527
"eslint-plugin-svelte": "^3.11.0",

www/svelte.config.js

Lines changed: 2 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

www/svelte.config.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import adapter from '@sveltejs/adapter-static';
2+
import type { Config } from '@sveltejs/kit';
3+
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
4+
5+
export default <Config>{
6+
// Consult https://svelte.dev/docs/kit/integrations
7+
// for more information about preprocessors
8+
preprocess: vitePreprocess(),
9+
10+
kit: {
11+
// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
12+
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
13+
// See https://svelte.dev/docs/kit/adapters for more information about adapters.
14+
adapter: adapter()
15+
}
16+
};
17+
18+
/* Self-compilation setup: Do not edit! */
19+
if (process.env.COMPILE_JS === 'true') {
20+
const esbuild = await import('esbuild');
21+
esbuild
22+
.build({
23+
entryPoints: ['svelte.config.ts'],
24+
outfile: 'svelte.config.js',
25+
minify: true,
26+
platform: 'node',
27+
banner: { js: '// This is an @generated config. Your changes will be overwritten. Please edit `svelte.config.ts` instead.' }
28+
})
29+
.catch(() => process.exit(1));
30+
}

0 commit comments

Comments
 (0)