-
Notifications
You must be signed in to change notification settings - Fork 10
/
electron.vite.config.ts
104 lines (95 loc) · 2.96 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import { join, resolve } from 'path';
import { defineConfig, externalizeDepsPlugin, bytecodePlugin } from 'electron-vite';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import vueSetupExtend from 'unplugin-vue-setup-extend-plus/vite';
// import Inspect from 'vite-plugin-inspect';
import { readdirSync } from 'fs';
// import { Plugin } from 'vite';
// import { fileURLToPath } from 'url';
// import { Plugin, PluginOption, build } from 'vite';
// const __dirname = fileURLToPath(new URL('.', import.meta.url));
// (async () => {
// await build({
// root: path.resolve(__dirname, './src/apptemplate'),
// base: '/',
// build: {
// rollupOptions: {
// // ...
// }
// },
// plugins: [vue(), vueJsx() /* , Inspect() */, vueSetupExtend({})]
// });
// })();
const evtryPath = resolve(__dirname, './src/renderer');
const entrys = readdirSync(evtryPath).reduce((obj, dirname) => {
console.log(dirname);
obj[dirname] = join(evtryPath, dirname);
return obj;
}, {});
const keys = Object.keys(entrys);
console.log('keys', keys);
const paths = keys.filter((key) => key.endsWith('.html')).map((key) => key.replace('.html', ''));
console.log('paths', paths);
const getEntryPath = () => {
const pageEntry = {};
paths.forEach((path) => {
pageEntry[path] = resolve(__dirname, `src/renderer/${path}.html`);
});
return pageEntry;
};
const rendererInput = getEntryPath();
console.log('rendererInput', rendererInput);
// const userAppVue: Plugin = {
// name: 'userAppCopy',
// load(id, options) {
// if (id.indexOf('steptip') != -1) {
// console.log('userAppCopyLoad: ', id, options);
// }
// },
// transform(_code, id, _options) {
// if (id.indexOf('steptip') != -1) {
// console.log('userAppCopy: ', id, _code);
// }
// return _code;
// }
// };
export default defineConfig({
main: {
plugins: [externalizeDepsPlugin(), bytecodePlugin({ chunkAlias: 'index' })],
resolve: {
alias: {
'@shared': resolve('src/shared')
}
},
build: {
rollupOptions: {
output: {
manualChunks(id): string | void {
if (id.includes('index')) {
return 'index';
}
}
}
}
}
},
preload: {
plugins: [externalizeDepsPlugin(), bytecodePlugin()]
},
renderer: {
build: {
minify: 'esbuild',
rollupOptions: {
input: rendererInput
}
},
resolve: {
alias: {
'@renderer': resolve('src/renderer/src'),
'@shared': resolve('src/shared')
}
},
plugins: [vue(), vueJsx() /* , Inspect() */, vueSetupExtend({})]
}
});