2025-05-18 14:03:18 -07:00
|
|
|
import react from '@vitejs/plugin-react';
|
|
|
|
|
import { externalizeDepsPlugin, UserConfig } from 'electron-vite';
|
|
|
|
|
import { resolve } from 'path';
|
2025-05-20 19:23:36 -07:00
|
|
|
import conditionalImportPlugin from 'vite-plugin-conditional-import';
|
|
|
|
|
import dynamicImportPlugin from 'vite-plugin-dynamic-import';
|
|
|
|
|
|
|
|
|
|
const currentOSEnv = process.platform;
|
2025-05-18 14:03:18 -07:00
|
|
|
|
|
|
|
|
const config: UserConfig = {
|
|
|
|
|
main: {
|
2025-05-22 20:05:15 -07:00
|
|
|
build: {
|
|
|
|
|
outDir: './release/app/dist/main',
|
2025-05-22 21:19:05 -07:00
|
|
|
rollupOptions: {
|
|
|
|
|
external: ['source-map-support'],
|
|
|
|
|
},
|
2025-05-22 20:05:15 -07:00
|
|
|
},
|
2025-05-20 19:23:36 -07:00
|
|
|
define: {
|
|
|
|
|
'import.meta.env.IS_LINUX': JSON.stringify(currentOSEnv === 'linux'),
|
|
|
|
|
'import.meta.env.IS_MACOS': JSON.stringify(currentOSEnv === 'darwin'),
|
|
|
|
|
'import.meta.env.IS_WIN': JSON.stringify(currentOSEnv === 'win32'),
|
|
|
|
|
},
|
|
|
|
|
plugins: [
|
|
|
|
|
externalizeDepsPlugin(),
|
|
|
|
|
dynamicImportPlugin(),
|
|
|
|
|
conditionalImportPlugin({
|
|
|
|
|
currentEnv: currentOSEnv,
|
|
|
|
|
envs: ['win32', 'linux', 'darwin'],
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
'/@/main': resolve('src/main'),
|
|
|
|
|
'/@/shared': resolve('src/shared'),
|
|
|
|
|
},
|
|
|
|
|
},
|
2025-05-18 14:03:18 -07:00
|
|
|
},
|
|
|
|
|
preload: {
|
2025-05-22 20:05:15 -07:00
|
|
|
build: {
|
|
|
|
|
outDir: './release/app/dist/preload',
|
|
|
|
|
},
|
2025-05-18 14:03:18 -07:00
|
|
|
plugins: [externalizeDepsPlugin()],
|
2025-05-20 19:23:36 -07:00
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
'/@/preload': resolve('src/preload'),
|
|
|
|
|
'/@/shared': resolve('src/shared'),
|
|
|
|
|
},
|
|
|
|
|
},
|
2025-05-18 14:03:18 -07:00
|
|
|
},
|
|
|
|
|
renderer: {
|
2025-05-22 20:05:15 -07:00
|
|
|
build: {
|
|
|
|
|
outDir: './release/app/dist/web',
|
|
|
|
|
},
|
2025-05-18 14:03:18 -07:00
|
|
|
css: {
|
|
|
|
|
modules: {
|
|
|
|
|
generateScopedName: '[name]__[local]__[hash:base64:5]',
|
|
|
|
|
localsConvention: 'camelCase',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
plugins: [react()],
|
|
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
'/@/i18n': resolve('src/i18n'),
|
2025-05-20 19:23:36 -07:00
|
|
|
'/@/remote': resolve('src/remote'),
|
2025-05-18 14:03:18 -07:00
|
|
|
'/@/renderer': resolve('src/renderer'),
|
|
|
|
|
'/@/shared': resolve('src/shared'),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default config;
|