-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathvite.config.main.ts
48 lines (41 loc) · 1.42 KB
/
vite.config.main.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
import { resolve } from 'path';
import { type UserConfigFn } from 'vite';
import { folders, title, version } from './config/index.js';
const config: UserConfigFn = async ({ mode }) => {
const { defineConfig } = await import('vite');
const { default: tsconfigPaths } = await import('vite-tsconfig-paths');
const { default: target } = await import('vite-plugin-target');
const isDev = mode === 'development';
const rendererSource = process.env.RENDERER_SOURCE || (isDev ? 'localhost' : 'filesystem');
return defineConfig({
mode,
cacheDir: resolve(folders.cache, 'vite-main'),
define: {
'process.env.PRODUCT_NAME': JSON.stringify(title),
'process.env.VERSION': JSON.stringify(version),
'process.env.BUILD_SOURCE': JSON.stringify(process.env.BUILD_SOURCE),
'process.env.RENDERER_SOURCE': JSON.stringify(rendererSource),
'process.env.LOGGER': JSON.stringify(process.env.LOGGER),
},
build: {
outDir: folders.devBuild,
emptyOutDir: false,
lib: {
entry: folders.entrypoint.main,
fileName: () => 'main.cjs',
formats: ['cjs'],
},
rollupOptions: {
output: {
// entryFileNames: `[name].js`,
// chunkFileNames: `[name].js`,
globals: {
process: 'process',
},
},
},
},
plugins: [target({ 'electron-main': {} }), tsconfigPaths()],
});
};
export default config;