-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathvitest.config.mts
More file actions
33 lines (30 loc) · 941 Bytes
/
vitest.config.mts
File metadata and controls
33 lines (30 loc) · 941 Bytes
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
import { fileURLToPath } from "node:url";
import { defineConfig } from "vitest/config";
import { resolveDenoJson } from "./scripts/helper/resolver.ts";
export default defineConfig(() => {
const denoJson = resolveDenoJson();
const localImports: Record<string, string> = {};
/// 挑选出所有本地文件的映射配置
for (const [key, value] of Object.entries(denoJson.imports)) {
if (value.startsWith("./")) {
localImports[key] = fileURLToPath(import.meta.resolve(value));
}
}
/// 根据 alias 的特性,我们得先配置长的,再配置短的
const orderedAlias: Record<string, string> = {};
for (const key of Object.keys(localImports).sort().reverse()) {
orderedAlias[key] = localImports[key];
}
return {
esbuild: {
tsconfigRaw: {
compilerOptions: {
experimentalDecorators: true,
},
},
},
test: {
alias: orderedAlias,
},
};
});