import { resolve } from 'path'
import preprocess from 'svelte-preprocess'

const adapter = process.env.ADAPTER || '@sveltejs/adapter-node'
const options = JSON.parse(process.env.OPTIONS || '{}')

/** @type {import('@sveltejs/kit').Config} */
const config = {
    // Preprocessors docs: https://github.com/sveltejs/svelte-preprocess
    preprocess: preprocess(),

    kit: {
        target: '#housesof',

        // Vite configuration: https://vitejs.dev/config/
        vite: {
            resolve: {
                alias: {
                    $components: resolve('src/components'),
                    $modules: resolve('src/modules'),
                    $utils: resolve('src/utils'),
                }
            },
        },
    }
}

if (adapter) {
    config.kit.adapter = (await import(adapter)).default(options)
}

export default config