mirror of
https://github.com/lone-cloud/gerbil
synced 2026-06-04 04:04:44 -07:00
66 lines
1.8 KiB
TypeScript
66 lines
1.8 KiB
TypeScript
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import electron from 'vite-plugin-electron';
|
|
import renderer from 'vite-plugin-electron-renderer';
|
|
import { visualizer } from 'rollup-plugin-visualizer';
|
|
import { analyzer } from 'vite-bundle-analyzer';
|
|
import { resolve } from 'path';
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
plugins: [
|
|
react(),
|
|
electron([
|
|
{
|
|
// Main-Process entry file of the Electron App.
|
|
entry: 'electron/main.ts',
|
|
},
|
|
{
|
|
entry: 'electron/preload.ts',
|
|
onstart(options) {
|
|
// Notify the Renderer-Process to reload the page when the Preload-Scripts build is complete,
|
|
// instead of restarting the entire Electron App.
|
|
options.reload();
|
|
},
|
|
},
|
|
]),
|
|
renderer(),
|
|
// Bundle analyzer - only in build mode with ANALYZE flag
|
|
process.env.ANALYZE === 'true' &&
|
|
visualizer({
|
|
filename: 'dist/stats.html',
|
|
open: true,
|
|
gzipSize: true,
|
|
brotliSize: true,
|
|
template: 'treemap', // 'treemap', 'sunburst', 'network'
|
|
}),
|
|
// Alternative bundle analyzer that opens in browser
|
|
process.env.ANALYZE === 'server' &&
|
|
analyzer({
|
|
analyzerMode: 'server',
|
|
openAnalyzer: true,
|
|
}),
|
|
].filter(Boolean),
|
|
resolve: {
|
|
alias: {
|
|
'@': resolve(__dirname, './src'),
|
|
},
|
|
},
|
|
server: {
|
|
port: 5173,
|
|
},
|
|
build: {
|
|
// Generate source maps for better debugging in production
|
|
sourcemap: process.env.NODE_ENV === 'development',
|
|
// Split chunks for better caching
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks: {
|
|
// Separate vendor chunks for better caching
|
|
react: ['react', 'react-dom'],
|
|
// Add other vendor chunks as needed
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|