feishin/electron.vite.config.ts

72 lines
2.1 KiB
TypeScript
Raw Normal View History

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;
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'),
},
},
},
preload: {
2025-05-22 20:05:15 -07:00
build: {
outDir: './release/app/dist/preload',
},
plugins: [externalizeDepsPlugin()],
2025-05-20 19:23:36 -07:00
resolve: {
alias: {
'/@/preload': resolve('src/preload'),
'/@/shared': resolve('src/shared'),
},
},
},
renderer: {
2025-05-22 20:05:15 -07:00
build: {
outDir: './release/app/dist/web',
},
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'),
'/@/renderer': resolve('src/renderer'),
'/@/shared': resolve('src/shared'),
},
},
},
};
export default config;