perf(P6C.T11): bundle audit + opt-in visualizer for future audits
Audited the renderer bundle with rollup-plugin-visualizer. Top offenders (libsodium-sumo 292KB gz, livekit-client 177KB gz, @supabase 149KB gz) all have justified usage and no viable swap. Mediapipe + track-processors are already lazy-loaded into a separate chunk on first BackgroundBlur activation. Bundle has zero duplicate packages, no moment/lodash/dayjs, no syntax-highlight libs, no polyfills — already lean from T1+T6. Added rollup-plugin-visualizer as a dev-dep, gated behind ANALYZE=true so production builds pay no cost. Run with: ANALYZE=true pnpm --filter @chat-app/desktop build to regenerate stats.html (treemap) + stats.json (raw) for future audits.
This commit is contained in:
@@ -10,6 +10,9 @@
|
||||
import react from '@vitejs/plugin-react';
|
||||
import { defineConfig, externalizeDepsPlugin } from 'electron-vite';
|
||||
import path from 'node:path';
|
||||
import { visualizer } from 'rollup-plugin-visualizer';
|
||||
|
||||
const ANALYZE = process.env.ANALYZE === 'true';
|
||||
|
||||
const rendererAliases = {
|
||||
'@': path.resolve(__dirname, './src'),
|
||||
@@ -44,7 +47,30 @@ export default defineConfig({
|
||||
// bundle. Relative base produces `./assets/...` which works in both
|
||||
// dev (served from /) and packaged builds.
|
||||
base: './',
|
||||
plugins: [react()],
|
||||
// Visualizer plugins are gated behind ANALYZE=true so the production
|
||||
// build never pays the analysis cost. Re-enable with:
|
||||
// ANALYZE=true pnpm --filter @chat-app/desktop build
|
||||
// which writes apps/desktop/stats.html (treemap) + stats.json (raw).
|
||||
plugins: [
|
||||
react(),
|
||||
...(ANALYZE
|
||||
? [
|
||||
visualizer({
|
||||
filename: 'stats.html',
|
||||
template: 'treemap',
|
||||
gzipSize: true,
|
||||
brotliSize: true,
|
||||
open: false,
|
||||
}),
|
||||
visualizer({
|
||||
filename: 'stats.json',
|
||||
template: 'raw-data',
|
||||
gzipSize: true,
|
||||
brotliSize: true,
|
||||
}),
|
||||
]
|
||||
: []),
|
||||
],
|
||||
resolve: {
|
||||
alias: rendererAliases,
|
||||
},
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
"electron-vite": "^2.3.0",
|
||||
"postcss": "^8.4.49",
|
||||
"rimraf": "^6.0.0",
|
||||
"rollup-plugin-visualizer": "^7.0.1",
|
||||
"tailwindcss": "^3.4.15",
|
||||
"vite": "^5.4.11"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user