Files
sm-journal-plugin/vite.config.ts
Jakub Zych 85963b19ef test(16.2-06): keep happy-dom iframe pages offline in the editor tests
The preview tests put payloads with remote URLs into the preview frame's
srcdoc; happy-dom tried to load them (a DNS lookup of example.test on every
run). Tests must not reach the network.
2026-10-10 16:11:35 +02:00

42 lines
1.5 KiB
TypeScript

import { defineConfig } from 'vitest/config'
// Build of the Blog Editor custom element (D-16): one ES module entry,
// assets/src/blogeditor/index.ts, loaded by the admin SPA as a module script.
// It is built like a library entry (exports kept, fixed output names with no
// content hash; cabana appends ?v=<sha256 prefix> itself) but through the
// application pipeline, because Vite's library mode never minifies
// whitespace in ES output. The bundle and its stylesheet are committed under
// assets/dist and embedded through admin.go; scripts/check-dist.sh fails
// when they are stale.
export default defineConfig({
build: {
outDir: 'assets/dist',
emptyOutDir: true,
target: 'es2022',
modulePreload: false,
copyPublicDir: false,
reportCompressedSize: true,
rollupOptions: {
input: 'assets/src/blogeditor/index.ts',
preserveEntrySignatures: 'exports-only',
output: {
format: 'es',
entryFileNames: 'blogeditor.js',
chunkFileNames: 'blogeditor-[name].js',
assetFileNames: 'blogeditor[extname]',
inlineDynamicImports: true,
},
},
},
test: {
environment: 'happy-dom',
include: ['tests/**/*.test.ts'],
// Tests never reach the network: happy-dom must not load the pages of
// iframes (the preview frame's srcdoc holds test payloads with remote
// URLs).
environmentOptions: {
happyDOM: { settings: { disableIframePageLoading: true } },
},
},
})