import { fileURLToPath, URL } from 'node:url' import vue from '@vitejs/plugin-vue' import { defineConfig } from 'vitest/config' export default defineConfig({ plugins: [vue()], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)), // @g3soft/ui 里的图标来自 ../g3soft-libs 的 pnpm store,那份 @lucide/vue 自带一个 // vue 副本;vitest 会把它外部化交给 Node 原生加载,绕过上面的 dedupe, // 导致图标组件里的 inject 读到另一份 vue 的实例状态(Cannot destructure ... of undefined)。 // 别名到本项目自己的 @lucide/vue,其内部 import 'vue' 就会原生解析到本项目的 vue。 '@lucide/vue': fileURLToPath(new URL('./node_modules/@lucide/vue', import.meta.url)), }, dedupe: ['vue', 'vue-router', 'pinia'], }, test: { environment: 'happy-dom', // 单元测试统一放 tests/(镜像 src 结构),不贴源放在 src 里; // 所以这里只收 tests/**,src 下误放的测试不会被执行。 include: ['tests/**/*.{test,spec}.ts'], globals: true, }, })