This repository has no description
1import tailwindcss from "@tailwindcss/vite";
2import { sveltekit } from "@sveltejs/kit/vite";
3import Icons from "unplugin-icons/vite";
4import { defineConfig } from "vitest/config";
5import oauthMetadata from "./static/oauth-client-metadata.json";
6import path from "node:path";
7import { fileURLToPath } from "node:url";
8import { storybookTest } from "@storybook/addon-vitest/vitest-plugin";
9import { playwright } from "@vitest/browser-playwright";
10const dirname =
11 typeof __dirname !== "undefined" ? __dirname : path.dirname(fileURLToPath(import.meta.url));
12
13// More info at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon
14const devHost = process.env.VITE_DEV_HOST ?? "127.0.0.1";
15const devPort = Number(process.env.VITE_DEV_PORT ?? 5173);
16const devRedirectUri = `http://127.0.0.1:${devPort}/oauth/callback`;
17const devClientId = `http://localhost?redirect_uri=${encodeURIComponent(devRedirectUri)}&scope=${encodeURIComponent(oauthMetadata.scope)}`;
18export default defineConfig({
19 plugins: [
20 {
21 name: "oauth-env",
22 config(_config, { command }) {
23 process.env.VITE_OAUTH_CLIENT_ID ??=
24 command === "serve" ? devClientId : oauthMetadata.client_id;
25 process.env.VITE_OAUTH_REDIRECT_URI ??=
26 command === "serve" ? devRedirectUri : oauthMetadata.redirect_uris[0];
27 process.env.VITE_OAUTH_SCOPE ??= oauthMetadata.scope;
28 }
29 },
30 tailwindcss(),
31 Icons({
32 compiler: "svelte"
33 }),
34 sveltekit()
35 ],
36 resolve: {
37 alias: {
38 "$icon/": "~icons/lucide/"
39 }
40 },
41 server: {
42 host: devHost,
43 port: devPort,
44 strictPort: true,
45 allowedHosts: [".ts.net"]
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});