import { defineConfig } from "cypress";
import dsv from "@rollup/plugin-dsv"

import { fileURLToPath } from "url";
import vitePreprocessor from "cypress-vite";

export default defineConfig({
  e2e: {
    baseUrl: "http://localhost:3000",
		viewportHeight: 900,
		viewportWidth: 1660,
		supportFile: false,
		specPattern: "./src/cypress/e2e/**/*.{ts,js}",
		setupNodeEvents(on, config) {
				on("file:preprocessor", vitePreprocessor({
					optimizeDeps: {
						exclude: ["@ibcornelsen/database"]
					},
					resolve: {
						alias: {
							"#": fileURLToPath(new URL("./src", import.meta.url)),
							"#components": fileURLToPath(new URL("./src/components", import.meta.url)),
							"#lib": fileURLToPath(new URL("./src/lib", import.meta.url))
						}
					},
					base: fileURLToPath(new URL("./src", import.meta.url)),
					build: {
						commonjsOptions: {
							transformMixedEsModules: false
						}
					},
					plugins: [dsv()]
				}))
		},
  },
  component: {
    devServer: {
      framework: "svelte",
      bundler: "vite"
    },
  }
});
