feishin/electron.vite.config.ts

67 lines
2 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';
2025-05-24 03:47:14 -07:00
import { ViteEjsPlugin } from 'vite-plugin-ejs';
2025-05-20 19:23:36 -07:00
const currentOSEnv = process.platform;
const config: UserConfig = {
main: {
2025-05-22 20:05:15 -07:00
build: {
2025-05-22 21:19:05 -07:00
rollupOptions: {
external: ['source-map-support'],
},
2025-06-09 01:28:23 -07:00
sourcemap: true,
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: {
plugins: [externalizeDepsPlugin()],
2025-05-20 19:23:36 -07:00
resolve: {
alias: {
'/@/preload': resolve('src/preload'),
'/@/shared': resolve('src/shared'),
},
},
},
renderer: {
css: {
modules: {
generateScopedName: 'fs-[name]-[local]',
localsConvention: 'camelCase',
},
},
2025-05-24 03:47:14 -07:00
plugins: [react(), ViteEjsPlugin({ web: false })],
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;