Files
HellCon/vite.config.ts
T
2026-10-30 13:39:16 +01:00

29 lines
1.2 KiB
TypeScript

/// <reference types="vitest/config" />
import vue from '@vitejs/plugin-vue';
import { defineConfig } from 'vite';
const DEV_STYLE_SRC = "style-src 'self'";
export default defineConfig({
plugins: [
vue(),
// index.html's Content-Security-Policy allows no inline styles, the dev server injects the CSS
// through JavaScript. A nonce lets only those style elements through, so the dev server enforces
// the same policy as the production build, which links the CSS as files.
{
name: 'dev-csp',
apply: 'serve',
config: () => ({ html: { cspNonce: 'dev' } }),
transformIndexHtml(html) {
if (!html.includes(DEV_STYLE_SRC)) throw new Error(`dev-csp: index.html has no "${DEV_STYLE_SRC}"`);
return html.replace(DEV_STYLE_SRC, `${DEV_STYLE_SRC} 'nonce-dev'`);
},
},
],
// The dev server would inline small images like gitea.svg as data: URLs, which index.html's
// Content-Security-Policy blocks. The production build links them as files either way.
build: { assetsInlineLimit: 0 },
// Playwright runs e2e.spec.ts and backend/, which Vitest would pick up too.
test: { include: ['src/**/*.test.ts'] },
});