Bulk Messaging System

Documentation

Build system and distribution

Introduction#

This page explains the build system architecture and distribution pipeline for the desktop application. It covers:

  • 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 ensures assets resolve correctly when served from 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 both Electron and React outputs.
  • Extra resources include preload and assets.
  • 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 18 with npm cache
    • 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 and extra resources are included via electron-builder.

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 depends on packaged files and extra resources.
  • 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 preload and extraResources scoped to reduce payload size.
  • 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 and extraResources entries.
    • 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#

The build system uses Vite for fast React bundling and development, integrates Electron for cross-platform desktop delivery, and automates distribution via electron-builder and GitHub Actions. By keeping asset paths relative, scoping resources carefully, and validating CI steps, teams can reliably produce production-ready apps across Windows, macOS, and Linux.

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.