diff options
Diffstat (limited to 'svelte.config.js')
| -rw-r--r-- | svelte.config.js | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/svelte.config.js b/svelte.config.js index 5e64863..dbef20d 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,11 +1,20 @@ +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: 'target/ui', + pages: path.join(outDir, 'ui'), fallback: 'index.html', }), files: { @@ -22,7 +31,7 @@ const config = { appTemplate: 'ui/app.html', errorTemplate: 'ui/error.html', }, - outDir: 'target/svelte-kit', + outDir: path.join(outDir, 'svelte-kit'), }, preprocess: vitePreprocess(), }; |
