-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
59 lines (56 loc) · 1.58 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
import vue from '@vitejs/plugin-vue'
import { execSync } from 'node:child_process'
import { fileURLToPath, URL } from 'node:url'
import { presetAttributify, presetIcons, presetUno } from 'unocss'
import UnoCSS from 'unocss/vite'
import AutoImport from 'unplugin-auto-import/vite'
import ElementPlus from 'unplugin-element-plus/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import Components from 'unplugin-vue-components/vite'
import { defineConfig } from 'vite'
function exeCmd(cmd: string) {
return execSync(cmd).toString().trim()
}
function getGitInfo() {
return {
author: exeCmd('git log -1 --format=%an'),
subject: exeCmd('git log -1 --format=%s'),
commit: exeCmd('git log -1 --format=%h'),
commitLong: exeCmd('git log -1 --format=%H'),
timestampt: exeCmd('git log -1 --format=%at'),
time: exeCmd('git log -1 --format=%aI'),
}
}
// https://vitejs.dev/config/
export default defineConfig({
base: '/torrents/',
build: {
target: 'esnext',
},
define: {
__GIT_INFO__: getGitInfo(),
},
plugins: [
vue(),
AutoImport({
resolvers: [ElementPlusResolver()],
}),
Components({
resolvers: [ElementPlusResolver()],
}),
ElementPlus({}),// 自动导入样式
// https://venerable-strudel-d42cce.netlify.app/guide/
UnoCSS({
presets: [
presetUno(), // 基本预设
presetAttributify(), // 属性化支持
presetIcons(), // 图标支持
],
}),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
})