Something went wrong. Try again.
Monorepo for Tangled tangled.org
Something went wrong. Try again.
TypeScript
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118import tailwindcss from "@tailwindcss/vite";import { sveltekit } from "@sveltejs/kit/vite";import Icons from "unplugin-icons/vite";import { defineConfig } from "vitest/config";import oauthMetadata from "./src/lib/oauth-client-metadata";import path from "node:path";import { fileURLToPath } from "node:url";import { storybookTest } from "@storybook/addon-vitest/vitest-plugin";import { playwright } from "@vitest/browser-playwright";const dirname = typeof __dirname !== "undefined" ? __dirname : path.dirname(fileURLToPath(import.meta.url));
// More info at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addonconst devHost = process.env.VITE_DEV_HOST ?? "127.0.0.1";const devPort = Number(process.env.VITE_DEV_PORT ?? 5173);// docker desktop's macos file sharing never forwards inotify to the container,// so an edit on the host lands on disk but the watcher never fires and hmr goes// stale. polling is the only way to see those writes, and only the container// needs itconst watch = process.env.VITE_WATCH_POLL === "true" ? { usePolling: true, interval: 300 } : undefined;const allowedHosts = [ ".ts.net", ...(process.env.VITE_ALLOWED_HOSTS?.split(",") .map((h) => h.trim()) .filter(Boolean) ?? [])];const devRedirectUri = `http://127.0.0.1:${devPort}/oauth/callback`;const devClientId = `http://localhost?redirect_uri=${encodeURIComponent(devRedirectUri)}&scope=${encodeURIComponent(oauthMetadata.scope)}`;export default defineConfig({ plugins: [ { name: "oauth-env", config(_config, { command }) { process.env.VITE_OAUTH_CLIENT_ID ??= command === "serve" ? devClientId : oauthMetadata.client_id; process.env.VITE_OAUTH_REDIRECT_URI ??= command === "serve" ? devRedirectUri : oauthMetadata.redirect_uris[0]; process.env.VITE_OAUTH_SCOPE ??= oauthMetadata.scope; } }, tailwindcss(), Icons({ compiler: "svelte" }), sveltekit() ], resolve: { alias: { "$icon/": "~icons/lucide/" } }, server: { host: devHost, port: devPort, strictPort: true, allowedHosts, watch }, // pierre's worker entry pulls all of shiki (300+ lang/theme chunks). left to // runtime discovery it triggers a re-optimize mid-page and in-flight dep // requests 504 silently. dev-only, the production build ignores it optimizeDeps: { include: [ "@pierre/diffs", "@pierre/diffs/worker", "@pierre/diffs/ssr", "@pierre/diffs/edit" ], exclude: ["@pierre/diffs/react"] }, 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}"] } }, { extends: true, plugins: [ // The plugin will run tests for the stories defined in your Storybook config // See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest storybookTest({ configDir: path.join(dirname, ".storybook") }) ], // vite only crawls kit routes here, so undeclared story deps would // optimize mid-run and wedge chromium; sanitize-html is cjs optimizeDeps: { noDiscovery: true, include: ["storybook/test", "sanitize-html"] }, test: { name: "storybook", browser: { enabled: true, headless: true, provider: playwright({}), instances: [ { browser: "chromium" } ] } } } ] }});