/
vite.config.ts
82 lines (78 loc) · 2.1 KB
/
vite.config.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import { resolve } from 'pathe'
import type { UserConfig } from 'vite'
import { defineConfig } from 'vite'
import Vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import AutoImport from 'unplugin-auto-import/vite'
import Unocss from 'unocss/vite'
import Pages from 'vite-plugin-pages'
import { presetAttributify, presetIcons, presetUno } from 'unocss'
// for debug:
// open a static file serve to share the report json
// and ui using the link to load the report json data
const debugLink = 'http://127.0.0.1:4173/__vitest__'
export const config: UserConfig = {
root: __dirname,
base: '/__vitest__/',
resolve: {
dedupe: ['vue'],
alias: {
'~/': `${resolve(__dirname, 'client')}/`,
'@vitest/ws-client': `${resolve(__dirname, '../ws-client/src/index.ts')}`,
},
},
define: {
__REPORT__: false,
},
plugins: [
Vue(),
Unocss({
presets: [
presetUno(),
presetAttributify(),
presetIcons(),
],
shortcuts: {
'bg-base': 'bg-white dark:bg-[#111]',
'bg-overlay': 'bg-[#eee]:50 dark:bg-[#222]:50',
'bg-header': 'bg-gray-500:5',
'bg-active': 'bg-gray-500:8',
'bg-hover': 'bg-gray-500:20',
'border-base': 'border-gray-500:10',
'tab-button': 'font-light op50 hover:op80 h-full px-4',
'tab-button-active': 'op100 bg-gray-500:10',
},
}),
Components({
dirs: ['client/components'],
dts: resolve(__dirname, './client/components.d.ts'),
}),
Pages({
dirs: ['client/pages'],
}),
AutoImport({
dts: resolve(__dirname, './client/auto-imports.d.ts'),
imports: [
'vue',
'vue-router',
'@vueuse/core',
],
}),
{
name: 'debug-html-report',
apply: 'serve',
transformIndexHtml(html) {
return html.replace('<!-- !LOAD_METADATA! -->', `<script>window.METADATA_PATH="${debugLink}/html.meta.json"</script>`)
},
},
],
build: {
outDir: './dist/client',
},
optimizeDeps: {
include: [
'vue',
],
},
}
export default defineConfig(config)