generated from knifezred/fridayboot-electron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
electron.vite.config.ts
82 lines (73 loc) · 2.19 KB
/
electron.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 ElegantVueRouter from '@elegant-router/vue/vite'
import dayjs from 'dayjs'
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import { resolve } from 'path'
import { loadEnv } from 'vite'
import { RouteMeta } from 'vue-router'
import { setupVitePlugins } from './build/plugins'
export default defineConfig((configEnv) => {
const viteEnv = loadEnv(configEnv.mode, process.cwd())
const buildTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
return {
main: {
plugins: [externalizeDepsPlugin()]
},
preload: {
plugins: [externalizeDepsPlugin()]
},
renderer: {
resolve: {
alias: {
'@renderer': resolve('src/renderer/src'),
'@main': resolve('src/main/'),
'@resources': resolve('resources/')
}
},
css: {
preprocessorOptions: {
scss: {
additionalData: `@use "src/renderer/src/styles/scss/global.scss" as *;`
}
}
},
define: {
BUILD_TIME: JSON.stringify(buildTime)
},
plugins: [
setupVitePlugins(viteEnv),
ElegantVueRouter({
cwd: 'src/renderer',
pageDir: 'src/renderer/src/views',
alias: {
'@renderer': 'src/renderer/src'
},
layouts: {
base: 'src/renderer/src/layouts/base-layout/index.vue',
blank: 'src/renderer/src/layouts/blank-layout/index.vue'
},
routePathTransformer(routeName, routePath) {
const key = routeName
if (key === 'login') {
const modules = ['pwd-login', 'register', 'reset-pwd']
const moduleReg = modules.join('|')
return `/login/:module(${moduleReg})?`
}
return routePath
},
onRouteMetaGen(routeName) {
const key = routeName
const constantRoutes = ['login', '403', '404', '500']
const meta: Partial<RouteMeta> = {
title: key,
i18nKey: `route.${key}`
}
if (constantRoutes.includes(key)) {
meta.constant = true
}
return meta
}
})
]
}
}
})