This repository has no description
1/// <reference types="vitest/config" />
2import tailwindcss from "@tailwindcss/vite";
3import { sveltekit } from "@sveltejs/kit/vite";
4import Icons from "unplugin-icons/vite";
5import { defineConfig } from "vitest/config";
6import oauthMetadata from "./static/oauth-client-metadata.json";
7import path from "node:path";
8import { fileURLToPath } from "node:url";
9import { storybookTest } from "@storybook/addon-vitest/vitest-plugin";
10import { playwright } from "@vitest/browser-playwright";
11const dirname =
12 typeof __dirname !== "undefined" ? __dirname : path.dirname(fileURLToPath(import.meta.url));
13
14// More info at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon
15const devHost = process.env.VITE_DEV_HOST ?? "127.0.0.1";
16const devPort = Number(process.env.VITE_DEV_PORT ?? 5173);
17const devRedirectUri = `http://127.0.0.1:${devPort}/oauth/callback`;
18const devClientId = `http://localhost?redirect_uri=${encodeURIComponent(devRedirectUri)}&scope=${encodeURIComponent(oauthMetadata.scope)}`;
19export default defineConfig({
20 plugins: [
21 {
22 name: "oauth-env",
23 config(_config, { command }) {
24 process.env.VITE_OAUTH_CLIENT_ID ??=
25 command === "serve" ? devClientId : oauthMetadata.client_id;
26 process.env.VITE_OAUTH_REDIRECT_URI ??=
27 command === "serve" ? devRedirectUri : oauthMetadata.redirect_uris[0];
28 process.env.VITE_OAUTH_SCOPE ??= oauthMetadata.scope;
29 }
30 },
31 tailwindcss(),
32 Icons({
33 compiler: "svelte"
34 }),
35 sveltekit()
36 ],
37 resolve: {
38 alias: {
39 "$icon/": "~icons/lucide/"
40 }
41 },
42 server: {
43 host: devHost,
44 port: devPort,
45 strictPort: true
46 },
47 test: {
48 expect: {
49 requireAssertions: true
50 },
51 projects: [
52 {
53 extends: "./vite.config.ts",
54 test: {
55 name: "server",
56 environment: "node",
57 include: ["src/**/*.{test,spec}.{js,ts}"],
58 exclude: ["src/**/*.svelte.{test,spec}.{js,ts}"]
59 }
60 },
61 {
62 extends: true,
63 plugins: [
64 // The plugin will run tests for the stories defined in your Storybook config
65 // See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest
66 storybookTest({
67 configDir: path.join(dirname, ".storybook")
68 })
69 ],
70 test: {
71 name: "storybook",
72 browser: {
73 enabled: true,
74 headless: true,
75 provider: playwright({}),
76 instances: [
77 {
78 browser: "chromium"
79 }
80 ]
81 }
82 }
83 }
84 ]
85 }
86});