xtablo-source/apps/external/vite.config.ts

45 lines
1.2 KiB
TypeScript
Raw Normal View History

2025-10-23 09:54:45 +00:00
/// <reference types="vite/client" />
2025-10-24 15:06:42 +00:00
import { cloudflare } from "@cloudflare/vite-plugin";
2025-10-23 09:54:45 +00:00
import tailwindcss from "@tailwindcss/vite";
import react from "@vitejs/plugin-react";
2025-10-24 15:06:42 +00:00
import { dirname } from "path";
2025-10-23 09:54:45 +00:00
import { fileURLToPath } from "url";
2025-10-24 15:06:42 +00:00
import { defineConfig, PluginOption } from "vite";
2025-10-23 09:54:45 +00:00
import tsconfigPaths from "vite-tsconfig-paths";
const __dirname = dirname(fileURLToPath(import.meta.url));
// https://vitejs.dev/config/
2025-10-24 15:06:42 +00:00
export default defineConfig(({ mode }) => {
const plugins: PluginOption[] = [
react(),
// visualizer() as PluginOption,
tailwindcss(),
tsconfigPaths({ ignoreConfigErrors: true }),
2025-10-24 15:06:42 +00:00
];
// Only include cloudflare plugin when not in test mode
if (mode !== "test" && process.env.VITEST !== "true") {
plugins.push(cloudflare({ inspectorPort: 9231 }));
2025-10-24 15:06:42 +00:00
}
return {
plugins,
server: {
cors: false,
},
define: process.env.VITEST
? {
"import.meta.env.VITE_SUPABASE_URL": JSON.stringify("https://test.supabase.co"),
"import.meta.env.VITE_SUPABASE_ANON_KEY": JSON.stringify("test-anon-key"),
}
: undefined,
test: {
globals: true,
environment: "jsdom",
setupFiles: "./src/setupTests.ts",
2025-10-23 09:54:45 +00:00
},
2025-10-24 15:06:42 +00:00
};
2025-10-23 09:54:45 +00:00
});