forked from vuepress/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vitest.config.ts
36 lines (34 loc) · 1.11 KB
/
vitest.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
import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { defineConfig } from 'vitest/config'
const getSubDirectories = (dir: string): string[] =>
fs
.readdirSync(dir)
.filter((item) => fs.statSync(path.join(dir, item)).isDirectory())
const root = path.dirname(fileURLToPath(import.meta.url))
const nonScopedPackages = ['vuepress', 'vuepress-vite', 'vuepress-webpack']
const corePackages = getSubDirectories(path.resolve(root, 'packages'))
const ecosystemPackages = getSubDirectories(
path.resolve(root, 'ecosystem')
).filter((item) => !nonScopedPackages.includes(item))
export default defineConfig({
resolve: {
alias: [
{
find: new RegExp(`^@vuepress/(${corePackages.join('|')})$`),
replacement: path.resolve(root, './packages/$1/src/index.ts'),
},
{
find: new RegExp(`^@vuepress/(${ecosystemPackages.join('|')})$`),
replacement: path.resolve(root, './ecosystem/$1/src/index.ts'),
},
],
},
test: {
coverage: {
provider: 'istanbul',
reporter: ['clover', 'json', 'lcov', 'text'],
},
},
})