-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.mts
106 lines (102 loc) · 2.38 KB
/
vite.config.mts
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import react from '@vitejs/plugin-react'
import { visualizer } from 'rollup-plugin-visualizer'
import { defineConfig, type PluginOption, type Plugin } from 'vite'
import { VitePWA } from 'vite-plugin-pwa'
const pwaPlugin = VitePWA({
registerType: 'autoUpdate',
manifest: {
name: 'SKOR',
short_name: 'SKOR',
start_url: '/',
icons: [
{
src: '/android-chrome-192x192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: '/android-chrome-512x512.png',
sizes: '512x512',
type: 'image/png',
},
],
theme_color: '#0a91b1',
background_color: '#0a91b1',
display: 'standalone',
},
workbox: {
globPatterns: ['**/*.{js,css,html,ico,png,svg,mp3,woff,woff2}'],
},
})
const htmlPlugin: Plugin = {
name: 'html-transform',
apply: 'build',
transformIndexHtml(html: string) {
return html.replace(
'<!-- inject-analytics-script -->',
`<script async src="https://umami.kolberger.eu/script.js" data-website-id="9cd0ee03-0f5e-4414-81d2-c2de1a3e1d99"></script>`,
)
},
}
const optionalPlugins = (['1', 'true'].includes(
process.env.ANALYZE?.toLowerCase(),
)
? [
visualizer({
template: 'treemap', // or sunburst
open: true,
gzipSize: true,
brotliSize: true,
}),
]
: []) as unknown as PluginOption[]
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), pwaPlugin, htmlPlugin, ...optionalPlugins],
server: {},
test: {
setupFiles: 'test/setup-test.ts',
coverage: {
all: true,
provider: 'v8',
reporter: ['json-summary', 'json', 'lcov'],
reportOnFailure: true,
thresholds: {
lines: 60,
branches: 60,
functions: 60,
statements: 60,
},
include: ['src/**'],
exclude: [
'src/App.tsx',
'src/main.tsx',
'**/*.types.ts',
'src/feature/router',
'src/pages',
'**/*.d.ts',
],
},
globals: true,
environment: 'happy-dom',
css: false,
onConsoleLog(msg) {
if (
msg.includes(
'The above error occurred in the <TestComponent> component:',
)
) {
return false
}
},
},
build: {
rollupOptions: {
output: {
manualChunks: {
collaboration: ['yjs', 'y-webrtc', 'y-indexeddb'],
},
},
},
},
})