import { sveltekit } from "@sveltejs/kit/vite";
import { defineConfig } from "vitest/config";
import tailwindcss from "@tailwindcss/vite";
import Icons from "unplugin-icons/vite";
import { resolve } from "path";

export default defineConfig({
    plugins: [sveltekit(), tailwindcss(), Icons({ compiler: "svelte" })],

    ssr: {
        external: [
            "argon2",
            "node-gyp-build",
            "sharp",
            "@img/sharp-linux-x64",
            "@img/sharp-linuxmusl-x64",
            "@img/sharp-wasm32",
        ],
    },

    resolve: {
        alias: {
            "@core": resolve(__dirname, "../../packages/logic/core"),
            "@domains": resolve(__dirname, "../../packages/logic/domains"),
            "@/core": resolve(__dirname, "../../packages/logic/core"),
            "@/domains": resolve(__dirname, "../../packages/logic/domains"),
        },
    },

    test: {
        expect: { requireAssertions: true },

        projects: [
            {
                extends: "./vite.config.ts",

                test: {
                    name: "server",
                    environment: "node",
                    include: ["src/**/*.{test,spec}.{js,ts}"],
                    exclude: ["src/**/*.svelte.{test,spec}.{js,ts}"],
                },
            },
        ],
    },
});
