-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathelectron.vite.config.js
More file actions
105 lines (99 loc) · 2.63 KB
/
electron.vite.config.js
File metadata and controls
105 lines (99 loc) · 2.63 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* eslint-disable import/no-extraneous-dependencies */
import { defineConfig } from 'electron-vite';
import path, { resolve } from 'path';
import vue from '@vitejs/plugin-vue';
import svgLoader from 'vite-svg-loader';
import { fileURLToPath } from 'url';
import util from 'util';
import { exec } from 'child_process';
const asyncExec = util.promisify(exec);
async function prepareVersioningEnv() {
try {
const execData = await asyncExec('git describe --tags --abbrev=0');
process.env.VITE_APP_VERSION = execData.stdout;
} catch (err) {
process.env.VITE_APP_VERSION = '';
}
try {
const execData = await asyncExec(`git log -1 --format=%ai ${process.env.VITE_APP_VERSION}`);
process.env.VITE_APP_BUILD_DATE = execData.stdout;
} catch (err) {
process.env.VITE_APP_BUILD_DATE = '';
}
try {
const execData = await asyncExec('git rev-parse --abbrev-ref HEAD');
process.env.VITE_APP_BRANCH = execData.stdout;
} catch (err) {
process.env.VITE_APP_BRANCH = '';
}
}
const filename = fileURLToPath(import.meta.url);
const pathSegments = path.dirname(filename);
export default defineConfig(async () => {
process.env.VITE_STATIC_URL = 'static:/';
await prepareVersioningEnv();
return {
root: './',
plugins: [
vue(),
svgLoader(),
],
resolve: {
alias: {
'@': path.resolve(pathSegments, './src'),
'@root': path.resolve(pathSegments, './'),
},
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
},
main: {
plugins: [
vue(),
svgLoader(),
],
resolve: {
alias: {
'@': path.resolve(pathSegments, './src'),
'@root': path.resolve(pathSegments, './'),
},
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
},
root: '.',
build: {
publicDir: resolve(__dirname, 'public'),
lib: {
entry: './src/electron/main.js',
},
},
},
preload: {
build: {
publicDir: resolve(__dirname, 'public'),
lib: {
entry: './src/electron/preload.js',
},
},
},
renderer: {
plugins: [
vue(),
svgLoader(),
],
resolve: {
alias: {
'@': path.resolve(pathSegments, './src'),
'@root': path.resolve(pathSegments, './'),
},
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
},
root: '.',
build: {
publicDir: resolve(__dirname, 'public'),
rollupOptions: {
input: {
index: './index.html',
},
},
},
},
};
});