Repository navigation
Expand file tree
/
Copy pathvite.config.ts
More file actions
70 lines (68 loc) · 2.28 KB
/
Copy pathvite.config.ts
File metadata and controls
70 lines (68 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { sentryVitePlugin } from '@sentry/vite-plugin';
import adapter from '@sveltejs/adapter-static';
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vitest/config';
const plausible = process.env.PUBLIC_PLAUSIBLE_SCRIPT ?? '';
const pulse = plausible ? [new URL(plausible).origin as `${string}.${string}`] : [];
const sentry = process.env.PUBLIC_SENTRY_DSN ?? '';
const oops = sentry ? [new URL(sentry).origin as `${string}.${string}`] : [];
const uploadMaps = Boolean(process.env.SENTRY_AUTH_TOKEN && process.env.SENTRY_URL);
export default defineConfig({
define: {
'import.meta.env.PUBLIC_PLAUSIBLE_SCRIPT': JSON.stringify(plausible),
'import.meta.env.PUBLIC_SENTRY_DSN': JSON.stringify(sentry)
},
build: {
sourcemap: uploadMaps && 'hidden',
assetsInlineLimit: (file) => (file.endsWith('.woff2') ? false : undefined)
},
plugins: [
sveltekit({
compilerOptions: {
runes: ({ filename }) =>
filename.split(/[/\\]/).includes('node_modules') ? undefined : true
},
adapter: adapter(),
// the 404 page is served at any depth, so assets need absolute paths
paths: { relative: false },
prerender: {
entries: [
'*',
'/api/providers.json',
'/api/criteria.json',
'/schema/provider.json',
'/sitemap.xml',
'/llms.txt',
'/logo.png'
]
},
csp: {
mode: 'hash',
directives: {
'default-src': ['self'],
'script-src': ['self', ...pulse],
'connect-src': ['self', ...pulse, ...oops],
'img-src': ['self', 'data:'],
'style-src': ['self', 'unsafe-inline'],
'font-src': ['self'],
'base-uri': ['none'],
'form-action': ['none'],
'frame-ancestors': ['none']
}
}
}),
uploadMaps &&
sentryVitePlugin({
telemetry: false,
release: { create: false, finalize: false, setCommits: false, deploy: false },
bundleSizeOptimizations: { excludeDebugStatements: true, excludeTracing: true },
sourcemaps: {
assets: '.svelte-kit/output/client/**',
filesToDeleteAfterUpload: '.svelte-kit/output/**/*.map'
}
})
],
test: {
include: ['tests/**/*.test.ts']
}
});