-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.test.js
34 lines (30 loc) · 909 Bytes
/
vite.config.test.js
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
/// <reference types="vitest" />
import { defineConfig } from 'vite'
// https://vitejs.dev/config/
export default defineConfig(async ({ mode }) => {
/** @type import('vite/dist/node/index').UserConfigExport */
const config = {
plugins: [],
optimizeDeps: {
exclude: ["vue-demi"],
},
test: {
globals: true,
environment: 'jsdom'
}
};
// mode = 'vue2' | 'vue3'
if (mode === 'vue3') {
const vue = (await import('@vitejs/plugin-vue')).default;
config.plugins.push(vue())
config.test.include = ['test/**/v3.test.ts'];
}
if (mode === 'vue2') {
const vue2 = (await import('vite-plugin-vue2')).default;
const scriptSetup = (await import('unplugin-vue2-script-setup/vite')).default;
config.plugins.push(vue2.createVuePlugin())
config.plugins.push(scriptSetup())
config.test.include = ['test/**/v2.test.ts'];
}
return config;
})