Repository navigation
Expand file tree
/
Copy pathvite.config.ts
More file actions
121 lines (112 loc) · 3.34 KB
/
Copy pathvite.config.ts
File metadata and controls
121 lines (112 loc) · 3.34 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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import tailwindcss from '@tailwindcss/vite';
import react from '@vitejs/plugin-react';
import { defineBrowserCommand, playwright } from '@vitest/browser-playwright';
import dts from 'vite-plugin-dts';
import { defineConfig } from 'vitest/config';
import pack from './package.json' with { type: 'json' };
export default defineConfig({
plugins: [
react(),
tailwindcss(),
dts({
compilerOptions: { rootDir: 'src' },
exclude: ['test', 'dev', '**/*.config.ts'],
}),
],
build: {
lib: {
entry: {
index: './src/index.ts',
'api-contract': './src/api-contract/index.ts',
settings: './src/settings/index.ts',
},
name: 'shlink-web-component',
formats: ['es'], // Generate ES module only
},
rolldownOptions: {
// Make sure dependencies and peer dependencies are not bundled with the library
external: [...Object.keys(pack.dependencies), ...Object.keys(pack.peerDependencies), 'react/jsx-runtime'],
},
},
server: {
watch: {
ignored: ['**/dist/**', '**/.idea/**', '**/node_modules/**', '**/.git/**', '**/test/**'],
},
},
// Vitest recommended to add these dependencies here to avoid flaky tests
optimizeDeps: {
include: [
'@formkit/drag-and-drop/react',
'@fortawesome/free-regular-svg-icons',
'@fortawesome/free-solid-svg-icons',
'@fortawesome/react-fontawesome',
'@json2csv/plainjs',
'@testing-library/react',
'@shlinkio/data-manipulation',
'@shlinkio/shlink-frontend-kit',
'@shlinkio/shlink-js-sdk',
'@shlinkio/shlink-js-sdk/api-contract',
'@shlinkio/shlink-js-sdk/fetch',
'axe-core',
'bottlejs',
'bowser',
'clsx',
'compare-versions',
'date-fns',
'history',
'leaflet',
'qr-code-styling',
'react-dom/client',
'react-external-link',
'react-leaflet',
'react-router',
'react-swipeable',
'recharts',
],
},
test: {
globals: true,
clearMocks: true,
setupFiles: [
// Load styles in tests, as they affect how components look and behave, and are important for a11y contrast checks
'./dev/tailwind.css',
'./test/setup.ts',
],
// Propagate env vars from process.env, so that they can be accessed from tests via import.meta.env
env: process.env,
// Run tests in an actual browser
browser: {
provider: playwright({
// In CI, this instructs playwright to use a pre-existing Chrome instance
launchOptions: process.env.CI ? { channel: 'chrome' } : undefined,
}),
enabled: true,
headless: true,
screenshotFailures: false,
instances: [{ browser: 'chromium' }],
commands: {
listenForFileDownload: defineBrowserCommand(({ page }) => page.waitForEvent('download')),
},
},
coverage: {
provider: 'v8',
reportsDirectory: './coverage',
include: [
'src/**/*.ts',
'src/**/*.tsx',
'!src/index.ts',
'!src/container/*',
'!src/**/provideServices.ts',
'!src/**/ChartDimensionsContext.ts',
],
reporter: ['text', 'text-summary', 'clover', 'html'],
// Required code coverage. Lower than this will make the check fail
thresholds: {
statements: 92,
branches: 88,
functions: 85,
lines: 93,
},
},
},
});