Files
flyer-crawler.projectium.com/vite.config.ts
Torben Sorensen a4d5e95937
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 1m1s
some more re-org + fixes
2025-11-24 14:46:17 -08:00

67 lines
2.5 KiB
TypeScript

// vite.config.ts
/// <reference types="vitest" />
import path from 'path';
import { defineConfig } from 'vitest/config';
import react from '@vitejs/plugin-react';
/**
* This is the main configuration file for Vite and the Vitest 'unit' test project.
* When running `vitest`, it is orchestrated by `vitest.workspace.ts`, which
* separates the unit and integration test environments.
*/
export default defineConfig({
// Vite-specific configuration for the dev server, build, etc.
// This is inherited by all Vitest projects.
plugins: [react()],
server: {
port: 3000,
host: '0.0.0.0',
},
resolve: {
alias: {
// Use __dirname for a more robust path resolution
'@': path.resolve(__dirname, './src'),
// This alias ensures that any import of 'services/logger' is resolved
// to the browser-safe client version during the Vite build process.
// Server-side code should explicitly import 'services/logger.server'.
'services/logger': path.resolve(__dirname, './src/services/logger.client.ts'),
},
},
// Vitest-specific configuration for the 'unit' test project.
test: {
// By default, Vitest does not suppress console logs.
// The onConsoleLog hook is only needed if you want to conditionally filter specific logs.
// Keeping the default behavior is often safer to avoid missing important warnings.
environment: 'jsdom',
globalSetup: './src/tests/setup/global-setup.ts',
setupFiles: ['./src/tests/setup/unit-setup.ts'],
// Explicitly include all test files that are NOT integration tests.
include: ['src/**/*.test.{ts,tsx}'],
// Exclude integration tests and other non-test files from the unit test runner.
exclude: [
'**/node_modules/**',
'**/dist/**',
'**/*.integration.test.ts',
'**/*.e2e.test.ts'
],
coverage: {
provider: 'v8',
// We remove 'text' here. The final text report will be generated by `nyc` after merging.
reporter: ['html', 'json'],
reportsDirectory: './.coverage/unit',
clean: true,
include: ['src/**/*.{ts,tsx}'],
// Refine exclusions to be more comprehensive
exclude: [
'src/main.tsx',
'src/types.ts',
'src/tests/**', // Exclude all test setup and helper files
'src/**/*.test.{ts,tsx}', // Exclude test files themselves
'src/**/*.stories.{ts,tsx}', // Exclude Storybook stories
'src/**/*.d.ts', // Exclude type definition files
'src/components/icons/**', // Exclude icon components if they are simple wrappers
],
},
},
});