Bulk Messaging System

An Electron Desktop app for marketing campaign & broadcast management, using either whatsapp, gmail or a SMTP server

Build system and distribution

Introduction#

Vite bundles the React UI, Electron packages the desktop shell, and electron-builder produces platform installers.

  • Vite configuration for React frontend bundling and development server
  • electron-builder configuration for cross-platform distribution
  • package.json scripts for building, packaging, and releasing
  • GitHub Actions CI/CD pipeline for automated releases
  • Asset bundling and integration of React build artifacts with Electron
  • Build optimization strategies and production deployment considerations
  • Troubleshooting common build issues and environment-specific configurations

Project structure#

The build system centers around the Electron application located under the electron/ directory. The React frontend is built by Vite into dist-react/, which Electron serves in production. Distribution is handled by electron-builder using a dedicated configuration file. Automation is implemented via GitHub Actions.

Core components#

  • Vite configuration defines plugins, output directory, base path, and development server port.
  • Electron main process loads either the local dev server during development or the built React HTML in production.
  • Preload script exposes a secure IPC API to the renderer.
  • electron-builder coordinates packaging and target-specific outputs.
  • GitHub Actions automates builds and releases across macOS, Linux, and Windows.

Architecture overview#

The build and distribution pipeline integrates React/Vite, Electron, and electron-builder with GitHub Actions.

Detailed component analysis#

Vite configuration for React bundling and dev server#

  • Plugins: React and Tailwind CSS integrations are enabled.
  • Base path: Relative base so assets resolve when loaded inside Electron.
  • Output: dist-react is the build destination for the React app.
  • Dev server: Port 5173 with strictPort to coordinate with Electron’s dev loading.

Electron main process and asset loading#

  • Development mode: Loads the Vite dev server URL.
  • Production mode: Loads the built index.html from dist-react.
  • Error handling: Logs did-fail-load events for diagnostics.
  • Asset resolution: Uses relative paths so assets load correctly from dist-react.

Preload script and secure IPC bridge#

  • Exposes a typed API to the renderer via contextBridge.
  • Provides methods for Gmail, SMTP, file dialogs, progress tracking, and WhatsApp operations.
  • Registers listeners for status updates and unregisters them on teardown.

Electron builder configuration and targets#

  • App ID and packaging files include dist-react/**, src/electron/**, src/shared/**, and package.json.
  • Preload ships as src/electron/preload.cjs in files. There is no extraResources block.
  • Targets:
  • macOS: dmg
  • Linux: AppImage with category Utility
  • Windows: portable and msi

Package scripts for build, packaging, and release#

  • Development: concurrently starts Vite dev server and Electron main process.
  • Build: produces the React app in dist-react/.
  • Start/prod: builds then launches Electron in prod-like mode.
  • Platform-specific distribution: dist:mac, dist:win, dist:linux.
  • Linting and preview are also available.

GitHub actions CI/CD pipeline#

  • Triggers on version tags and manual dispatch.
  • Matrix builds for macOS (arm64), Linux (x64), and Windows (x64).
  • Steps:
  • Checkout code
  • Setup Node.js 20+ with npm cache (Vite 8)
  • Install dependencies (electron/package-lock.json)
  • Build React app
  • Build platform-specific distributables
  • Upload artifacts
  • Create GitHub Releases with generated release notes

Asset bundling and integration with electron#

  • Vite emits index.html and assets into dist-react/.
  • Electron main process loads index.html in production.
  • Relative asset URLs ensure correct resolution.
  • Preload is packaged as src/electron/preload.cjs via the files glob.

Dependency analysis#

  • Vite depends on React and Tailwind plugins.
  • Electron main process depends on preload bridge and external libraries (whatsapp-web.js, nodemailer, googleapis).
  • electron-builder packages dist-react plus src/electron and src/shared.
  • GitHub Actions depends on Node.js setup and npm caching.

Performance considerations#

  • Use production builds for Electron distribution to minimize bundle sizes and enable minification.
  • Keep the files glob tight so unused source stays out of the package.
  • Prefer AppImage for Linux distributions to balance portability and performance.
  • Ensure asset URLs remain relative to avoid unnecessary network requests in production.
  • Cache Node dependencies in CI to speed up builds.

Troubleshooting guide#

Common build and runtime issues:

  • React dev server not reachable in Electron dev mode:
  • Verify Vite dev server port matches the URL loaded by Electron main process.
  • Confirm strictPort is enabled to prevent port conflicts.
  • Electron fails to load dist-react/index.html in production:
  • Ensure the build step runs before launching Electron.
  • Check that index.html and assets exist in dist-react/.
  • Asset 404 errors:
  • Confirm base path is set to “.” in Vite config.
  • Verify asset URLs in index.html match the emitted structure.
  • Distribution failures:
  • Validate electron-builder files globs and desktopIcon.icns.
  • Check platform-specific targets and signing requirements.
  • CI build failures:
  • Ensure Node.js version and npm cache align with package-lock.json.
  • Confirm artifacts are uploaded and released correctly.

Conclusion#

Dev uses Vite’s server; production loads static files from dist-react. Mixing those modes is a common “blank window” cause.

Appendices#

Appendix A: development and build commands#

  • Development: Start both React dev server and Electron main process concurrently.
  • Build: Produce the React app for Electron consumption.
  • Start/Prod: Build and launch Electron in production-like mode.
  • Platform builds: Generate platform-specific distributables.
  • Lint and preview: Maintain code quality and test the preview server.

Appendix B: electron entry points#

  • React entry: Initializes the root element and renders the App component.
  • App component: Renders the main application container.