import { defineConfig, type ViteUserConfig } from 'vitest/config'
import './internal/build/vue-compiler.ts'
import vue from '@vitejs/plugin-vue'
import { workspaceAliases } from './internal/build/workspaces.ts'
import { availableParallelism } from 'node:os'
import path from 'node:path'
export default defineConfig(async (): Promise<ViteUserConfig> => ({
plugins: [vue()],
resolve: { alias: await workspaceAliases() },
test: {
// Repository contract tests must not depend on a developer's local branding.
env: { PACKAGE_SCOPE: '94ai-plus', PACKAGE_CONFIG_FILE: path.resolve('package.config.example.mjs') },
environment: 'node',
server: { deps: { inline: ['element-plus', 'async-validator'] } },
coverage: {
provider: 'v8',
include: ['packages/*/src/**/*.{ts,tsx,js,jsx,vue}'],
exclude: ['**/*.d.ts'],
reportsDirectory: 'coverage',
reporter: ['text', 'html', 'json-summary', 'cobertura'],
clean: true,
reportOnFailure: false,
thresholds: { lines: 99, statements: 99, functions: 99, branches: 99 },
},
projects: [
{
extends: true,
test: {
name: 'checks',
// Bound CPU/subprocess contention on high-core hosts without relaxing timeouts.
maxWorkers: Math.min(2, availableParallelism()),
include: ['tests/**/*.test.ts'],
exclude: ['tests/build/**'],
},
},
{
extends: true,
test: {
name: 'build',
include: ['tests/build/**/*.test.ts'],
// Cold module imports, SSR and npm/tar subprocesses are integration
// work; the default 5s unit-test budget is too tight on Windows/CI.
testTimeout: 30_000,
globalSetup: ['./tests/build/setup.ts'],
},
},
],
},
}))