summaryrefslogtreecommitdiff
path: root/svelte.config.js
blob: dbef20da45251f75be8b64a61f26f1d21d09395f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import path from 'node:path';
import process from 'node:process';
import adapter from '@sveltejs/adapter-static';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';

// OUT_DIR is set by Cargo at build time:
// <https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts>
//
// When we're building through `vite` directly, it will not be set; we use "target" as a generic
// output directory to keep all the build products in one place.
const outDir = process.env['OUT_DIR'] ?? 'target';

/** @type {import('@sveltejs/kit').Config} */
const config = {
	kit: {
		adapter: adapter({
			pages: path.join(outDir, 'ui'),
			fallback: 'index.html',
		}),
		files: {
			hooks: {
				universal: 'ui/hooks',
				server: 'ui/hooks.server',
				client: 'ui/hooks.client',
			},
			assets: 'ui/static',
			lib: 'ui/lib',
			params: 'ui/params',
			routes: 'ui/routes',
			serviceWorker: 'ui/service-worker',
			appTemplate: 'ui/app.html',
			errorTemplate: 'ui/error.html',
		},
		outDir: path.join(outDir, 'svelte-kit'),
	},
	preprocess: vitePreprocess(),
};

export default config;