Building and Packaging
Trufos uses Electron Forge as its primary tool for building, packaging, and distributing the application. The configuration for Electron Forge is located in forge.config.ts.
  Configuration (forge.config.ts) 
 This file defines how Electron Forge handles the build and packaging process.
Key sections:
- packagerConfig: Options passed to- electron-packager.- asar: true: Packages the application source code into an ASAR archive for potentially faster load times and to hide source code.
- icon: './images/icon': Specifies the path to the application icon (without extension, Electron Forge handles platform-specific formats like- .icnsor- .ico).
- osxSign&- osxNotarize: macOS specific signing and notarization settings. These are conditionally configured based on environment variables (- APPLE_API_KEY,- APPLE_API_KEY_ID,- APPLE_API_ISSUER), enabling code signing and notarization if credentials are provided.
 
-  rebuildConfig: Configuration for rebuilding native Node modules (empty in this case, but important if native dependencies are used).
- makers: Defines the types of distributables to create.- MakerSquirrel: Creates a Windows installer (- Setup.exe) using Squirrel.Windows.
- MakerZIP: Creates a- .ziparchive, configured here for Linux (- ['linux']).
- MakerDMG: Creates a- .dmgdisk image for macOS.
 
- plugins:- AutoUnpackNativesPlugin: Automatically unpacks native Node modules from the ASAR archive, which is often necessary for them to function correctly.
- VitePlugin: Integrates Vite for building the main and renderer process code.- buildarray: Configures Vite builds for non-renderer code.- Main process entry: src/main/main.tswith configsrc/main/vite.config.ts.
- Preload script entry: src/main/preload.tswith configsrc/main/vite.config.ts.
 
- Main process entry: 
- rendererarray: Configures Vite builds for renderer process code.- Named main_windowwith entry point implicitly handled by Vite viaindex.htmland configsrc/renderer/vite.config.ts.
 
- Named 
 
- FusesPlugin: Allows toggling certain Electron security features at package time. This configuration enhances security by:- Disabling RunAsNode.
- Enabling cookie encryption.
- Disabling Node.js options environment variables and CLI inspect arguments.
- Enabling ASAR integrity validation and ensuring the app only loads from ASAR.
 
- Disabling 
 
- publishers: Configures how and where to publish releases.- @electron-forge/publisher-github: Configured to publish releases to GitHub under the- EXXETA/trufosrepository, marked as prereleases.
 
Build Process Commands
Defined in package.json:
- yarn package:- Runs electron-forge package.
- Builds the application and packages it into a platform-specific runnable format (e.g., an .appbundle on macOS, anexewith associated files on Windows) in theout/directory. This is an unpackaged version, not an installer.
 
- Runs 
- yarn run make:- Runs electron-forge make.
- First, it performs the packaging step (like yarn package).
- Then, it uses the specified makers(MakerSquirrel, MakerZIP, MakerDMG) to create distributable installers/archives (e.g.,Setup.exe,.dmg,.zip) in theout/make/directory.
 
- Runs 
- yarn publish:- Runs electron-forge publish.
- Builds, makes, and then publishes the application according to the publishersconfiguration (in this case, to GitHub Releases).
 
- Runs 
How Vite is Used
The VitePlugin in forge.config.ts orchestrates the use of Vite:
- Main Process & Preload Script: - Vite is configured in library mode for these entries (src/main/main.ts,src/main/preload.ts).
- The output is placed in .vite/build/(e.g.,.vite/build/main.js,.vite/build/preload.js).
- Electron Forge then uses these built files when packaging the application.
 
- Vite is configured in library mode for these entries (
- Renderer Process: - Vite builds the React application (src/renderer/).
- The output (HTML, JS, CSS assets) is placed in .vite/renderer/main_window_vite_renderer/.
- Electron Forge includes these assets in the packaged application, and the main window loads the index.htmlfrom this location.
 
- Vite builds the React application (
During development (yarn start), electron-forge start uses Vite’s development server for HMR (Hot Module Replacement) for the renderer process and rebuilds main/preload scripts as needed.