-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.ts
95 lines (94 loc) · 2.25 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
85
86
87
88
89
90
91
92
93
94
95
/// <reference types="vitest" />
import { defineConfig } from 'vite'
import path from 'node:path'
import react from '@vitejs/plugin-react'
import dts from 'vite-plugin-dts'
export default defineConfig({
plugins: [
react({
jsxRuntime: 'automatic',
}),
dts({
insertTypesEntry: true,
}),
],
build: {
/**
* The library shouldn't minified.
*/
minify: false,
lib: {
entry: path.resolve(process.cwd(), './src/index.ts'),
},
rollupOptions: {
input: {
index: 'src/index.ts',
},
external: [
'react',
'react-dom',
'react/jsx-runtime',
'@react-awesome/use-selection-range',
'@react-awesome/use-previous',
'@react-awesome/use-click-outside',
'@react-awesome/use-preserve-input-caret-position',
'@react-awesome/phone-input',
'@react-awesome/use-toggle',
'@react-awesome/use-breakpoint',
],
output: [
{
dir: 'dist',
entryFileNames: '[name].js',
chunkFileNames: '[name]-[chunk].js',
format: 'esm',
exports: 'named',
preserveModules: true,
},
{
dir: 'dist',
entryFileNames: '[name].cjs',
chunkFileNames: '[name]-[chunk].cjs',
format: 'cjs',
exports: 'named',
preserveModules: true,
},
],
},
},
test: {
globals: true,
testTimeout: 15_000,
environment: 'jsdom',
retry: 2,
poolOptions: {
threads: {
singleThread: true,
},
},
setupFiles: path.resolve(process.cwd(), '../../setup-test.tsx'),
include: [
/**
* Unit tests should only apply to helpers function only.
* For component testing, we should use Functional Test.
* Thus to avoid unnecessary tests we should use .tsx for components file only.
*/
'./src/**/*.spec.ts',
'./src/**/*.spec.tsx',
],
coverage: {
provider: 'istanbul',
include: ['**/*.ts', '**/*.tsx'],
reporter: ['text', 'json', 'html'],
/**
* minimum threshold range, should be 100
*/
thresholds: {
statements: 0,
functions: 0,
lines: 0,
branches: 0,
},
},
},
})