61 lines
1.4 KiB
TypeScript
61 lines
1.4 KiB
TypeScript
import { defineConfig } from 'vitest/config';
|
|
import react from '@vitejs/plugin-react';
|
|
import path from 'path';
|
|
|
|
const apiProxyTarget = process.env.API_PROXY_TARGET ?? 'http://localhost:3000';
|
|
|
|
export default defineConfig({
|
|
plugins: [
|
|
react(),
|
|
{
|
|
name: 'cmpp-production-build-guard',
|
|
apply: 'build',
|
|
configResolved(config) {
|
|
if (!config.isProduction) {
|
|
throw new Error('CMPP frontend builds require NODE_ENV=production; refusing a development React release.');
|
|
}
|
|
},
|
|
},
|
|
],
|
|
cacheDir: 'node_modules/.vite-cmpp',
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, 'src'),
|
|
},
|
|
},
|
|
server: {
|
|
port: 5173,
|
|
strictPort: false,
|
|
proxy: {
|
|
'/api': {
|
|
target: apiProxyTarget,
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
optimizeDeps: {
|
|
noDiscovery: true,
|
|
include: [],
|
|
},
|
|
preview: {
|
|
proxy: {
|
|
'/api': {
|
|
target: apiProxyTarget,
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
test: {
|
|
environment: 'jsdom',
|
|
include: ['src/**/*.test.{ts,tsx}'],
|
|
exclude: ['api/**', 'outputs/**', 'dist/**', 'node_modules/**'],
|
|
setupFiles: ['./src/test/setup.ts'],
|
|
coverage: {
|
|
provider: 'v8',
|
|
reporter: ['text', 'json-summary'],
|
|
include: ['src/api/core/**/*.ts', 'src/apps/LoginPage.tsx', 'src/routes/RouteLoadBoundary.tsx'],
|
|
thresholds: { lines: 80, functions: 80, branches: 70, statements: 80 },
|
|
},
|
|
},
|
|
});
|