- Install pdfjs-dist v5 and add optimizeDeps pre-bundle config - New PdfViewer.svelte component: renders each page on a <canvas> with correct device-pixel-ratio scaling, overlays a text layer (enables text selection; foundation for annotations in #40), prev/next navigation, zoom controls, and lazy page rendering (only current ±1 pre-fetched — avoids freezing on multi-page documents) - Replace the <iframe> in documents/[id]/+page.svelte with PdfViewer; image attachments continue to use <img>; detection now uses doc.contentType instead of filename extension - Unit tests for navigation controls and page counter (pdfjs mocked) - E2E tests: PDF renders as canvas (not iframe), nav controls visible, image fallback stays as <img>; minimal.pdf fixture for upload tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
74 lines
2.0 KiB
TypeScript
74 lines
2.0 KiB
TypeScript
import { paraglideVitePlugin } from '@inlang/paraglide-js';
|
|
import devtoolsJson from 'vite-plugin-devtools-json';
|
|
import tailwindcss from '@tailwindcss/vite';
|
|
import { defineConfig } from 'vitest/config';
|
|
import { playwright } from '@vitest/browser-playwright';
|
|
import { sveltekit } from '@sveltejs/kit/vite';
|
|
|
|
export default defineConfig({
|
|
optimizeDeps: {
|
|
include: ['pdfjs-dist']
|
|
},
|
|
server: {
|
|
host: '0.0.0.0', // Erlaubt Zugriff von außen
|
|
port: 5173, // Standard SvelteKit Port
|
|
// Proxy für API-Aufrufe während der Entwicklung (Browser -> Vite -> Spring Boot)
|
|
proxy: {
|
|
'/api': {
|
|
target: process.env.API_PROXY_TARGET || 'http://localhost:8080',
|
|
changeOrigin: true,
|
|
// Inject Authorization header from the auth_token cookie so that
|
|
// browser-side fetch('/api/...') calls work the same as SSR fetches
|
|
// (which go through handleFetch in hooks.server.ts).
|
|
configure: (proxy) => {
|
|
proxy.on('proxyReq', (proxyReq, req) => {
|
|
const cookies = req.headers.cookie ?? '';
|
|
const match = cookies.match(/auth_token=([^;]+)/);
|
|
if (match) {
|
|
proxyReq.setHeader('Authorization', decodeURIComponent(match[1]));
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
},
|
|
plugins: [
|
|
tailwindcss(),
|
|
sveltekit(),
|
|
devtoolsJson(),
|
|
paraglideVitePlugin({
|
|
project: './project.inlang',
|
|
outdir: './src/lib/paraglide'
|
|
})
|
|
],
|
|
test: {
|
|
expect: { requireAssertions: true },
|
|
projects: [
|
|
{
|
|
extends: './vite.config.ts',
|
|
test: {
|
|
name: 'client',
|
|
browser: {
|
|
enabled: true,
|
|
provider: playwright(),
|
|
instances: [{ browser: 'chromium', headless: true }],
|
|
screenshotDirectory: 'test-results/screenshots',
|
|
screenshotFailures: true
|
|
},
|
|
include: ['src/**/*.svelte.{test,spec}.{js,ts}'],
|
|
exclude: ['src/lib/server/**']
|
|
}
|
|
},
|
|
{
|
|
extends: './vite.config.ts',
|
|
test: {
|
|
name: 'server',
|
|
environment: 'node',
|
|
include: ['src/**/*.{test,spec}.{js,ts}'],
|
|
exclude: ['src/**/*.svelte.{test,spec}.{js,ts}']
|
|
}
|
|
}
|
|
]
|
|
}
|
|
});
|