2024-10-30 15:06:21 +08:00
|
|
|
import { join } from "node:path"
|
2024-10-09 02:54:11 +08:00
|
|
|
import { defineConfig } from "vitest/config"
|
|
|
|
import autoImport from "unplugin-auto-import/vite"
|
|
|
|
import { resolveModuleExportNames } from "mlly"
|
2024-10-30 15:06:21 +08:00
|
|
|
import { projectDir } from "./shared/dir"
|
2024-10-09 02:54:11 +08:00
|
|
|
|
|
|
|
const h3Exports = await resolveModuleExportNames("h3", {
|
|
|
|
url: import.meta.url,
|
|
|
|
})
|
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
test: {
|
|
|
|
globals: true,
|
|
|
|
environment: "node",
|
2024-10-12 15:50:44 +08:00
|
|
|
include: ["server/**/*.test.ts", "shared/**/*.test.ts", "test/**/*.test.ts"],
|
2024-10-09 02:54:11 +08:00
|
|
|
},
|
2024-10-30 15:06:21 +08:00
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
"@shared": join(projectDir, "shared"),
|
|
|
|
"#": join(projectDir, "server"),
|
|
|
|
},
|
|
|
|
},
|
2024-10-09 02:54:11 +08:00
|
|
|
plugins: [
|
|
|
|
// https://github.com/unjs/nitro/blob/v2/src/core/config/resolvers/imports.ts
|
|
|
|
autoImport({
|
2024-10-30 15:06:21 +08:00
|
|
|
imports: [{
|
2024-10-09 02:54:11 +08:00
|
|
|
from: "h3",
|
|
|
|
imports: h3Exports.filter(n => !/^[A-Z]/.test(n) && n !== "use"),
|
|
|
|
}, {
|
|
|
|
from: "ofetch",
|
|
|
|
imports: ["$fetch", "ofetch"],
|
|
|
|
}],
|
2024-10-30 15:06:21 +08:00
|
|
|
dirs: ["server/utils", "shared"],
|
|
|
|
dts: false,
|
2024-10-09 02:54:11 +08:00
|
|
|
}),
|
|
|
|
],
|
|
|
|
})
|