generated from StanfordBDHG/NextJSTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvite.config.ts
84 lines (80 loc) · 2.35 KB
/
vite.config.ts
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
//
// This source file is part of the Stanford Biodesign Digital Health Spezi Web Design System open-source project
//
// SPDX-FileCopyrightText: 2024 Stanford University and the project authors (see CONTRIBUTORS.md)
//
// SPDX-License-Identifier: MIT
//
/// <reference types="vitest" />
/// <reference types="vite/client" />
import fs from 'node:fs'
import path from 'node:path'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
import { configDefaults } from 'vitest/config'
/**
* Tuple of [package name, package entry point]
* */
const entires = [
['index', 'src/index.ts'],
['SpeziProvider', 'src/SpeziProvider.tsx'],
['forms', 'src/forms/index.tsx'],
...fs
.readdirSync(path.resolve(__dirname, `src/components`))
.map((name) => [`components/${name}`, `src/components/${name}/index.tsx`]),
...fs
.readdirSync(path.resolve(__dirname, `src/molecules`))
.map((name) => [`molecules/${name}`, `src/molecules/${name}/index.tsx`]),
...fs
.readdirSync(path.resolve(__dirname, `src/modules`))
.map((name) => [`modules/${name}`, `src/modules/${name}/index.tsx`]),
...fs
.readdirSync(path.resolve(__dirname, `src/utils`))
.map((name) => [`utils/${name}`, `src/utils/${name}/index.ts`]),
]
const testExclude = [
'**/*.stories.tsx',
'./postcss.config.js',
'./tailwind.config.js',
'./src/tests/storybook.tsx',
]
export default defineConfig({
root: '.',
plugins: [
react(),
dts({
insertTypesEntry: true,
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
build: {
lib: {
entry: Object.fromEntries(
entires.map((entry) => [entry[0], path.resolve(__dirname, entry[1])]),
),
name: '@stanfordspezi/spezi-web-design-system',
fileName: (format, name) => {
if (format === 'es') return `${name}.js`
return `${name}.${format}`
},
},
rollupOptions: {
external: ['react', 'next-intl', 'react/jsx-runtime', 'react-dom'],
},
},
// @ts-expect-error TypeScript doesn't detect interface overload by vitest
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['./testSetup.ts'],
exclude: [...testExclude, ...configDefaults.exclude],
coverage: {
exclude: [...testExclude, ...(configDefaults.coverage.exclude ?? [])],
},
},
})