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 allowedHosts: [".ts.net"]
47 },
48 test: {
49 expect: {
50 requireAssertions: true
51 },
52 projects: [
53 {
54 extends: "./vite.config.ts",
55 test: {
56 name: "server",
57 environment: "node",
58 include: ["src/**/*.{test,spec}.{js,ts}"],
59 exclude: ["src/**/*.svelte.{test,spec}.{js,ts}"]
60 }
61 },
62 {
63 extends: true,
64 plugins: [
65 // The plugin will run tests for the stories defined in your Storybook config
66 // See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest
67 storybookTest({
68 configDir: path.join(dirname, ".storybook")
69 })
70 ],
71 test: {
72 name: "storybook",
73 browser: {
74 enabled: true,
75 headless: true,
76 provider: playwright({}),
77 instances: [
78 {
79 browser: "chromium"
80 }
81 ]
82 }
83 }
84 }
85 ]
86 }
87});