-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathvite.config.ts
39 lines (37 loc) · 1.01 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
import {defineConfig, type UserConfig} from 'vite'
import {configDefaults} from 'vitest/config'
import pkg from './package.json'
const {dependencies = {}, peerDependencies = {}} = pkg as any
const makeRegex = (dep: string) => new RegExp(`^${dep}(/.*)?$`)
const excludeAll = (obj: {[pkg: string]: string}) =>
Object.keys(obj).map(dep => makeRegex(dep))
export default defineConfig(() => {
return {
build: {
// keep debugging readable
minify: false,
target: 'es2020',
lib: {
entry: ['./src/index.js'],
formats: ['es', 'cjs'],
},
rollupOptions: {
preserveModules: true,
// externalize deps that shouldn't be bundled into the library
external: [
/^node:.*/,
...excludeAll(dependencies),
...excludeAll(peerDependencies),
],
},
},
test: {
globals: true,
testTimeout: 20_000,
exclude: [...configDefaults.exclude, 'dist/**', 'dist-types/**'],
coverage: {
exclude: [...configDefaults.coverage!.exclude!, 'package-scripts.cjs'],
},
},
} as UserConfig
})