-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
53 lines (49 loc) · 1.29 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
import { join as joinPath, resolve as resolvePath } from "node:path"
import { fileURLToPath } from "node:url"
import { defineConfig } from "vitest/config"
import tsconfigJson from "./tsconfig.json"
const projectDirectory = joinPath(fileURLToPath(import.meta.url), "..")
export default defineConfig(() => ({
build: {
emptyOutDir: true,
minify: "esbuild" as const,
reportCompressedSize: false,
rollupOptions: {
output: {
entryFileNames: "main.mjs",
},
},
},
cacheDir: inProjectDirectory("node_modules/.cache/"),
plugins: [],
resolve: {
alias: getAliasesFromTsconfig(),
},
ssr: {
noExternal: ["@actions/core", "@actions/github", "undici", "zod"],
},
test: {
coverage: {
include: ["src/**/*.ts"],
exclude: ["src/**/*.tests.ts"],
provider: "v8" as const,
reportsDirectory: inProjectDirectory(
"node_modules/.cache/vitest/coverage/",
),
},
include: ["src/**/*.tests.ts"],
},
}))
function getAliasesFromTsconfig(): Record<string, string> {
return Object.fromEntries(
Object.entries(tsconfigJson.compilerOptions.paths).map(
([alias, [path]]) => [
alias.slice(0, -"/*".length),
inProjectDirectory(path.slice(0, -"/*".length)),
],
),
)
}
function inProjectDirectory(relativePath: string): string {
return resolvePath(projectDirectory, relativePath)
}