Fecha loop B+C — Web consome @sar/api-interface em runtime, não só build. - Vite proxy /api → localhost:3000 (zero CORS em dev, mesma URL em prod via Nginx) - api-client.ts: fetch wrapper parseando RFC 9457 problem+json em ApiError - useApiPing: TanStack Query + PingResponseSchema.parse — drift servidor falha alto - FoundationStatus pill na Topbar (verde/vermelho/cinza + Tooltip com requestId) Validado via curl proxy:4200 → 200 ok contratual; /nope → 404 problem+json. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
/// <reference types='vitest' />
|
|
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
|
import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin';
|
|
|
|
export default defineConfig(() => ({
|
|
root: import.meta.dirname,
|
|
cacheDir: '../../node_modules/.vite/apps/web',
|
|
server: {
|
|
port: 4200,
|
|
host: 'localhost',
|
|
// Proxy /api/* → API Nest em :3000 (default API_PORT).
|
|
// Evita CORS em dev e mantém URL relativa no código da Web — em produção,
|
|
// mesmo origin via Nginx (/api/* → backend).
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://localhost:3000',
|
|
changeOrigin: false,
|
|
},
|
|
},
|
|
},
|
|
preview: {
|
|
port: 4200,
|
|
host: 'localhost',
|
|
},
|
|
plugins: [react(), nxViteTsPaths(), nxCopyAssetsPlugin(['*.md'])],
|
|
// Uncomment this if you are using workers.
|
|
// worker: {
|
|
// plugins: () => [ nxViteTsPaths() ],
|
|
// },
|
|
build: {
|
|
outDir: '../../dist/apps/web',
|
|
emptyOutDir: true,
|
|
reportCompressedSize: true,
|
|
commonjsOptions: {
|
|
transformMixedEsModules: true,
|
|
},
|
|
},
|
|
test: {
|
|
name: 'web',
|
|
watch: false,
|
|
globals: true,
|
|
environment: 'jsdom',
|
|
include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
reporters: ['default'],
|
|
coverage: {
|
|
reportsDirectory: '../../coverage/apps/web',
|
|
provider: 'v8' as const,
|
|
},
|
|
},
|
|
}));
|