| 1 | import react from "@vitejs/plugin-react-swc"; |
| 2 | import { resolve } from "path"; |
| 3 | import tailwindcss from "tailwindcss"; |
| 4 | import { defineConfig } from "vitest/config"; |
| 5 | |
| 6 | // https://vitejs.dev/config/ |
| 7 | export default defineConfig({ |
| 8 | plugins: [react(), tailwindcss()], |
| 9 | build: { |
| 10 | // Change the output .js filename to not include a hash |
| 11 | rollupOptions: { |
| 12 | input: { |
| 13 | index: resolve(__dirname, "index.html"), |
| 14 | indexConsole: resolve(__dirname, "indexConsole.html"), |
| 15 | }, |
| 16 | output: { |
| 17 | entryFileNames: `assets/[name].js`, |
| 18 | chunkFileNames: `assets/[name].js`, |
| 19 | assetFileNames: `assets/[name].[ext]`, |
| 20 | }, |
| 21 | }, |
| 22 | }, |
| 23 | server: { |
| 24 | cors: { |
| 25 | origin: "*", |
| 26 | methods: ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"], |
| 27 | allowedHeaders: ["*", "Content-Type", "Authorization"], |
| 28 | credentials: true, |
| 29 | }, |
| 30 | }, |
| 31 | test: { |
| 32 | globals: true, |
| 33 | environment: "jsdom", |
| 34 | setupFiles: "./src/util/test/setupTests.ts", |
| 35 | onConsoleLog(log, type) { |
| 36 | if (type === "stderr") { |
| 37 | if ( |
| 38 | [ |
| 39 | "contentEditable", |
| 40 | "An update to Chat inside a test was not wrapped in act", |
| 41 | "An update to TipTapEditor inside a test was not wrapped in act", |
| 42 | "An update to ThinkingIndicator inside a test was not wrapped in act", |
| 43 | "The current testing environment is not configured to support act", |
| 44 | "target.getClientRects is not a function", |
| 45 | "prosemirror", |
| 46 | ].some((text) => log.includes(text)) |
| 47 | ) { |
| 48 | return false; |
| 49 | } |
| 50 | } |
| 51 | return true; |
| 52 | }, |
| 53 | onUnhandledRejection(err) { |
| 54 | // Suppress ProseMirror DOM errors in test environment |
| 55 | if ( |
| 56 | err.message?.includes("getClientRects") || |
| 57 | err.message?.includes("prosemirror") |
| 58 | ) { |
| 59 | return false; |
| 60 | } |
| 61 | return true; |
| 62 | }, |
| 63 | }, |
| 64 | }); |