-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathvite.config.ts
More file actions
123 lines (113 loc) · 3.74 KB
/
vite.config.ts
File metadata and controls
123 lines (113 loc) · 3.74 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
122
123
import tailwindcss from '@tailwindcss/vite';
import react from '@vitejs/plugin-react';
import { playwright } from '@vitest/browser-playwright';
import { resolve } from 'path';
import dts from 'vite-plugin-dts';
import { defineConfig } from 'vitest/config';
import pack from './package.json';
// eslint-disable-next-line no-restricted-exports
export default defineConfig({
plugins: [react(), tailwindcss(), dts({ rollupTypes: true })],
build: {
lib: {
entry: {
index: resolve(__dirname, 'src/index.ts'),
'api-contract': resolve(__dirname, 'src/api-contract/index.ts'),
'settings': resolve(__dirname, 'src/settings/index.ts'),
},
name: 'shlink-web-component',
formats: ['es'], // Generate ES module only
},
rollupOptions: {
// Make sure dependencies and peer dependencies are not bundled with the library
external: [...Object.keys(pack.dependencies), ...Object.keys(pack.peerDependencies), 'react/jsx-runtime'],
output: {
// This ensures generated CSS file is called index.css, not style.css
assetFileNames: 'index.[ext]',
},
},
},
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',
'@testing-library/user-event',
'@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,
setupFiles: [
'./test/__helpers__/setup.ts',
// Load styles in tests, as they affect how components look and behave, and are important for a11y contrast checks
'./dev/tailwind.css',
],
// 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(),
enabled: true,
headless: true,
screenshotFailures: false,
instances: [{ browser: 'chromium' }],
},
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,
},
},
// Workaround for bug in react-router (or vitest module resolution) which causes different react-router versions to
// be resolved for the main package and dependencies which have a peer dependency in react-router.
// This ensures always the same version is resolved.
// See https://github.com/remix-run/react-router/issues/12785 for details
// The bug can be reproduced in ^20.19 and in >=22.11
alias: {
'react-router': resolve(__dirname, 'node_modules/react-router/dist/development/index.mjs'),
},
},
});