-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathvite.config.base.ts
37 lines (35 loc) · 1.21 KB
/
vite.config.base.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
/// <reference types="vitest" />
import path from "path"
import fs from "fs"
import AutoImport from "unplugin-auto-import/vite"
import { defineConfig } from "vitest/config"
// const autoImport = AutoImport({
// dts: "./test/auto-imports.d.ts",
// // include: [
// // /\.test\.[tj]sx?$/ // .ts, .tsx, .js, .jsx
// // ],
// imports: [
// "vitest"
// ]
// })
export default function makeConfig(dirName?: string) {
const prefix = path.resolve(__dirname, "packages")
const packages = fs.readdirSync(prefix).map(f => prefix + "/" + f).filter(f => fs.lstatSync(f).isDirectory() )
const cfg = {
// eslint-disable-next-line @typescript-eslint/no-var-requires
//plugins: [autoImport],
test: {
include: ["./test/**/*.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
reporters: "verbose",
globals: true
},
resolve: {
alias: packages.map(pkg => ({ pkg, json: pkg + "/package.json"})).filter(_ => fs.existsSync(_.json)).reduce((acc, { pkg, json}) => {
acc[JSON.parse(fs.readFileSync(json, "utf-8")).name] = path.resolve(pkg, "src")
return acc
}, { }) // "effect-app/Prelude": path.join(__dirname, "packages/core/src/Prelude.code.ts")
}
}
//console.log(cfg)
return cfg
}