-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.mts
59 lines (57 loc) · 1.53 KB
/
vite.config.mts
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
import {defineConfig} from 'vite'
import {configDefaults} from 'vitest/config'
import pkg from './package.json'
import dts from 'vite-plugin-dts'
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 {
// Keep the meta info
define: {
'import.meta.env': 'import.meta.env',
'import.meta.env.BASE_URL': 'import.meta.env.BASE_URL',
'import.meta.env.DEV': 'import.meta.env.DEV',
},
build: {
// keep debugging readable
minify: false,
target: 'es2020',
lib: {
entry: ['./src', './src/vite.ts', './src/qwik.ts'],
formats: ['es', 'cjs'],
fileName: (format, entryName) =>
`${entryName}.${format === 'es' ? 'mjs' : 'cjs'}`,
},
rollupOptions: {
output: {
preserveModules: true,
},
// externalize deps that shouldn't be bundled into the library
external: [
// Our virtual modules
/@i18n\/.*/,
/^node:.*/,
...excludeAll(dependencies),
...excludeAll(peerDependencies),
],
},
},
plugins: [
dts({
exclude: ['**/fixture/**/*', '/**/*.test.*'],
entryRoot: 'src',
// We combine everything so the virtual module types are included
rollupTypes: true,
include: ['src'],
}),
],
test: {
globals: true,
testTimeout: 20_000,
exclude: [...configDefaults.exclude, 'dist/**'],
forceRerunTriggers: ['**/fixture/**/*'],
},
}
})