-
Notifications
You must be signed in to change notification settings - Fork 22
/
vite.config.ts
63 lines (60 loc) · 1.71 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
import vue from '@vitejs/plugin-vue'
import path from 'path'
import { defineConfig } from 'vite'
import electron, { startup, treeKillSync } from 'vite-plugin-electron'
import { VitePWA } from 'vite-plugin-pwa'
import vuetify from 'vite-plugin-vuetify'
import { getVersion } from './src/libs/non-browser-utils'
// Check if we're running in Electron mode or building the application
const isElectron = process.env.ELECTRON === 'true'
const isBuilding = process.argv.includes('build')
export default defineConfig({
plugins: [
(isElectron || isBuilding) &&
electron({
entry: 'electron/main.ts',
vite: {
build: {
outDir: 'dist/electron',
},
},
onstart: () => {
// @ts-ignore: process.electronApp exists in vite-plugin-electron but not in the types
if (process.electronApp) {
// @ts-ignore: process.electronApp.pid exists in vite-plugin-electron but not in the types
treeKillSync(process.electronApp.pid)
}
startup()
},
}),
vue(),
vuetify({
autoImport: true,
}),
VitePWA({
registerType: 'autoUpdate',
devOptions: {
enabled: true,
},
includeAssets: ['favicon.ico', 'apple-touch-icon.png', 'masked-icon.svg'],
}),
].filter(Boolean),
define: {
'process.env': {},
'__APP_VERSION__': JSON.stringify(getVersion().version),
'__APP_VERSION_DATE__': JSON.stringify(getVersion().date),
'__APP_VERSION_LINK__': JSON.stringify(getVersion().link),
},
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
test: {
globals: true,
environment: 'jsdom',
},
server: {
host: '0.0.0.0',
},
})