### Start Electron App Source: https://github.com/electron/forge/blob/main/packages/external/create-electron-app/README.md After initializing the app and navigating into the project directory, use this command to start the Electron development server. ```sh cd my-app npm start ``` -------------------------------- ### Install Dependencies Source: https://github.com/electron/forge/blob/main/CONTRIBUTING.md Install all project dependencies using Yarn. ```bash yarn install ``` -------------------------------- ### Configure @electron-forge/maker-pkg Source: https://github.com/electron/forge/blob/main/packages/maker/pkg/README.md Example configuration for the @electron-forge/maker-pkg. Specify the 'name' and any 'config' options, such as the 'keychain' for signing. ```javascript { name: '@electron-forge/maker-pkg', config: { keychain: 'my-secret-ci-keychain' } } ``` -------------------------------- ### Clone, Install, and Build Forge Repository Source: https://github.com/electron/forge/blob/main/CONTRIBUTING.md Clones the Electron Forge repository, installs all dependencies, and builds the TypeScript code. This is the initial setup for local development. ```bash git clone https://github.com/electron/forge cd forge # Installs all dependencies yarn # Builds all the TS code yarn build ``` -------------------------------- ### Configure Squirrel Installer Source: https://github.com/electron/forge/blob/main/packages/maker/squirrel/README.md Use this configuration to set up the Squirrel.Windows installer with certificate details. Ensure your certificate file and password are correct. ```javascript { name: '@electron-forge/maker-squirrel', config: { certificateFile: './cert.pfx', certificatePassword: 'this-is-a-secret' } } ``` -------------------------------- ### Configure Flatpak Maker Options Source: https://github.com/electron/forge/blob/main/packages/maker/flatpak/README.md Example of how to configure the Flatpak maker with specific categories and MIME types. ```javascript { name: '@electron-forge/maker-flatpak', config: { options: { categories: ['Video'], mimeType: ['video/h264'] } } } ``` -------------------------------- ### Configure AppX Maker Source: https://github.com/electron/forge/blob/main/packages/maker/appx/README.md Example configuration for the @electron-forge/maker-appx package. Specify publisher details and the path to your development certificate. ```javascript { name: '@electron-forge/maker-appx', config: { publisher: 'CN=developmentca', devCert: 'C:\\devcert.pfx', certPass: 'abcd' } } ``` -------------------------------- ### Configure Snapcraft Publisher Source: https://github.com/electron/forge/blob/main/packages/publisher/snapcraft/README.md Example configuration for the Snapcraft publisher in forge.config.js. Specifies the release channels for publishing. ```javascript module.exports = { // ... publishers: [ { name: '@electron-forge/publisher-snapcraft', config: { release: 'latest/edge, insider/stable' } } ] }; ``` -------------------------------- ### Install Fuses Plugin and Fuses Package Source: https://github.com/electron/forge/blob/main/packages/plugin/fuses/README.md Install the necessary packages as development dependencies using Yarn or npm. ```shell # Yarn yarn add --dev @electron-forge/plugin-fuses @electron/fuses ``` ```shell # npm npm i -D @electron-forge/plugin-fuses @electron/fuses ``` -------------------------------- ### Configure RPM Maker Source: https://github.com/electron/forge/blob/main/packages/maker/rpm/README.md Example configuration for the @electron-forge/maker-rpm package. Specify the maker name and provide custom options for the RPM build, such as application name and homepage. ```javascript { name: '@electron-forge/maker-rpm', config: { options: { name: 'QuickEdit', homepage: 'http://example.com' } } } ``` -------------------------------- ### Create New Electron Forge App Source: https://github.com/electron/forge/blob/main/README.md Use the create-electron-app CLI tool to initialize a new Electron Forge project. Ensure Node.js 16.4.0 or higher and Git are installed. ```bash npx create-electron-app@latest my-new-app # then cd my-new-app npm start ``` -------------------------------- ### Configure Snap Maker Source: https://github.com/electron/forge/blob/main/packages/maker/snap/README.md Configure the snap maker with version, features, and summary. Ensure you are on a Linux system with snapcraft installed to build snap targets. ```javascript { name: '@electron-forge/maker-snap', config: { version: '1.1.0', features: { audio: true, mpris: 'com.example.mpris', webgl: true }, summary: 'My application' } } ``` -------------------------------- ### Configure MSIX Maker Source: https://github.com/electron/forge/blob/main/packages/maker/msix/README.md Configure the MSIX maker with manifest variables and Windows signing options. Ensure the Windows 10 SDK is installed when building on Windows. ```javascript { name: '@electron-forge/maker-msix', config: { manifestVariables: { publisher: 'Electron Dev' }, windowsSignOptions: { certificatePassword: '12345' } } } ``` -------------------------------- ### Configure Vite Plugin in forge.config.js Source: https://github.com/electron/forge/blob/main/packages/plugin/vite/README.md Example configuration for the @electron-forge/plugin-vite in forge.config.js. It demonstrates how to specify entry points for the build process (main, preload, worker) and renderer configurations, leveraging Vite's familiar configuration structure. ```javascript // forge.config.js module.exports = { plugins: [ { name: '@electron-forge/plugin-vite', config: { // `build` can specify multiple entry builds, which can be Main process, Preload scripts, Worker process, etc. // If you are familiar with Vite configuration, it will look really familiar. build: [ { // `entry` is just an alias for `lib.entry` in the corresponding file of `config`. entry: 'src/main.js', config: 'vite.main.config.mjs' }, { entry: 'src/preload.js', config: 'vite.preload.config.mjs' } ], renderer: [ { name: 'main_window', config: 'vite.renderer.config.mjs' } ] } } ] }; ``` -------------------------------- ### Configure Electron Forge Webpack Plugin Source: https://github.com/electron/forge/blob/main/packages/plugin/webpack/README.md Example configuration for the @electron-forge/plugin-webpack in forge.config.js. Specify webpack configurations for main and renderer processes, and define renderer entry points. ```javascript // forge.config.js module.exports = { plugins: [ { name: '@electron-forge/plugin-webpack', config: { mainConfig: './webpack.main.config.js', renderer: { config: './webpack.renderer.config.js', entryPoints: [{ name: 'main_window', html: './src/renderer/index.html', js: './src/renderer/index.js', preload: { js: './src/preload.js' } }] } } } ] }; ``` -------------------------------- ### Configure Wix MSI Maker Source: https://github.com/electron/forge/blob/main/packages/maker/wix/README.md Specify the Wix MSI maker and its configuration options, including language and manufacturer. Ensure WiX Toolset's `light` and `candle` are installed. ```javascript { name: '@electron-forge/maker-wix', config: { language: 1033, manufacturer: 'My Awesome Company' } } ``` -------------------------------- ### Custom Template Module API Source: https://github.com/electron/forge/wiki/Custom-template-modules Export an object with configuration for your custom template module. This includes production and development dependencies, the path to your template files, and an optional post-copy hook for additional setup. ```javascript const path = require('path'); module.exports = { dependencies: ['react', 'react-dom'], // Production Dependencies devDependencies: [], // Development Dependencies templateDirectory: path.resolve(__dirname, './tmpl'), // Absolute path to a directory containing template files postCopy: (initDir, ora, lintStyle) => { // This function will be executed after we have installed dependencies and finished copying your templates // If you need to do asynchronous work return a Promise and we will wait for it to resolve. // For any long running tasks you should use the "ora" module provided to indicate the task in progress }, }; ``` -------------------------------- ### Initialize New Electron App Source: https://github.com/electron/forge/blob/main/packages/external/create-electron-app/README.md Run this command to create a new Electron app with the latest version of create-electron-app. This will set up a minimal boilerplate project. ```sh npx create-electron-app@latest my-app ``` -------------------------------- ### Switch to Main Branch and Pull Source: https://github.com/electron/forge/blob/main/CONTRIBUTING.md Ensure your local repository is up-to-date with the main branch before making changes. ```bash git switch main && git pull ``` -------------------------------- ### Initialize and Use Web Multi Logger Source: https://github.com/electron/forge/blob/main/packages/utils/web-multi-logger/README.md Instantiate the Logger, create separate tabs for different log streams, and run your application logic, directing logs to the appropriate tabs. Access the web console at http://localhost:9000. ```javascript import Logger from '@electron-forge/web-multi-logger'; const logger = new Logger(); const serverTab = logger.createTab('server'); const frontEndTab = logger.createTab('front_end'); runServerWithLogger(serverTab); runFrontEndWithLogger(frontEndTab); // Navigate to http://localhost:9000 in your browser ``` -------------------------------- ### BrowserWindow Preload Configuration Comparison Source: https://github.com/electron/forge/wiki/Using-'preload'-scripts Illustrates the difference in configuring the 'preload' option in BrowserWindow's webPreferences between a standard Electron application and one using Electron Forge. ```js // Normal Way const mainWindow = new BrowserWindow({ webPreferences: { preload: 'path/to/real/preload', }, }); ``` ```js // In electron-forge const mainWindow = new BrowserWindow({ webPreferences: { preload: 'path/to/preload-launcher.js', }, }); ``` -------------------------------- ### Package Electron App with Core API Source: https://github.com/electron/forge/blob/main/packages/api/core/README.md Use the `api.package` function to package the current directory as an Electron app. Remember that all API methods are asynchronous and return promises that should be handled for rejections. ```javascript import { api } from '@electron-forge/core'; // Package the current directory as an Electron app api.package(__dirname); ``` -------------------------------- ### Initialize Project with Local Forge Dependencies Source: https://github.com/electron/forge/blob/main/CONTRIBUTING.md Initializes a new Electron Forge project while linking local Forge dependencies. Ensure Forge is built and `yarn link:prepare` has been run. ```sh LINK_FORGE_DEPENDENCIES_ON_INIT=1 node path/to/forge/packages/api/cli/dist/electron-forge-init.js my-app ``` -------------------------------- ### Login to npm Source: https://github.com/electron/forge/blob/main/CONTRIBUTING.md Log in to your npm account to prepare for publishing packages. ```bash npm login ``` -------------------------------- ### Build and Link Local Forge Packages Source: https://github.com/electron/forge/blob/main/CONTRIBUTING.md Builds the Forge project and prepares local packages for symlinking. Use this to test local changes in a sample project. ```sh yarn build yarn link:prepare ``` -------------------------------- ### Configure Nucleus Publisher in forge.config.js Source: https://github.com/electron/forge/blob/main/packages/publisher/nucleus/README.md This configuration snippet shows how to set up the @electron-forge/publisher-nucleus in your forge.config.js file. Ensure you replace placeholder values with your actual Nucleus server details and token. It is recommended to use environment variables for the token. ```javascript module.exports = { // ... publishers: [ { name: '@electron-forge/publisher-nucleus', config: { host: 'https://my-nucleus.mysite.com', appId: 1, channelId: 'abcdefg', token: 'my-token' } } ] }; ``` -------------------------------- ### Configure Bitbucket Publisher in forge.config.js Source: https://github.com/electron/forge/blob/main/packages/publisher/bitbucket/README.md Configure the Bitbucket publisher in your `forge.config.js` file. Ensure you replace placeholders with your actual repository and authentication details. This target is for Bitbucket Cloud only. ```javascript module.exports = { // ... publishers: [ { name: '@electron-forge/publisher-bitbucket', config: { repository: { owner: 'myusername', name: 'myreponame' }, auth: { username: 'myusername', appPassword: 'mysecretapppassword' } } } ] }; ``` -------------------------------- ### Configure DMG Maker Source: https://github.com/electron/forge/blob/main/packages/maker/dmg/README.md Configure the @electron-forge/maker-dmg package with custom options like background image and DMG format. ```javascript { name: '@electron-forge/maker-dmg', config: { background: './assets/dmg-background.png', format: 'ULFO' } } ``` -------------------------------- ### Link Existing Project to Local Forge Packages Source: https://github.com/electron/forge/blob/main/CONTRIBUTING.md Links an existing project to your local Forge packages after running `yarn link:prepare`. This allows testing local Forge modifications within your project. ```sh yarn link @electron-forge/core --link-folder=path/to/forge/.links ``` -------------------------------- ### Configure GitHub Publisher in forge.config.js Source: https://github.com/electron/forge/blob/main/packages/publisher/github/README.md Configure the GitHub publisher in your forge.config.js file. Specify the repository owner and name, and set `prerelease` to true if you are publishing pre-release versions. ```javascript module.exports = { // ... publishers: [ { name: '@electron-forge/publisher-github', config: { repository: { owner: 'me', name: 'awesome-thing' }, prerelease: true } } ] }; ``` -------------------------------- ### Set Bitbucket Authentication via Environment Variables Source: https://github.com/electron/forge/blob/main/packages/publisher/bitbucket/README.md For enhanced security, use environment variables for Bitbucket authentication. Set `BITBUCKET_USERNAME` and `BITBUCKET_APP_PASSWORD` in a script or your shell environment. ```shell # env.sh BITBUCKET_USERNAME="myusername" BITBUCKET_APP_PASSWORD="mysecretapppassword" ``` ```shell source env.sh ``` -------------------------------- ### Configure Maker Zip Source: https://github.com/electron/forge/blob/main/packages/maker/zip/README.md To use the zip maker, include its name in the forge configuration. This maker has no configurable options. ```javascript { name: '@electron-forge/maker-zip' } ``` -------------------------------- ### Manually Publish New Package Source: https://github.com/electron/forge/blob/main/CONTRIBUTING.md Manually publish a newly added @electron-forge/ package to npm with public access. This step is performed before the normal release process to avoid Lerna errors. ```bash npm publish --access public ``` -------------------------------- ### Configure Electron Release Server Publisher Source: https://github.com/electron/forge/blob/main/packages/publisher/electron-release-server/README.md Add this configuration to your forge.config.js to publish artifacts to your Electron Release Server. ```javascript module.exports = { // ... publishers: [ { name: '@electron-forge/publisher-electron-release-server', config: { baseUrl: 'https://update.server.com', username: 'admin', password: 'admin' } } ] }; ``` -------------------------------- ### Configure Local Electron Plugin Source: https://github.com/electron/forge/blob/main/packages/plugin/local-electron/README.md Configure the @electron-forge/plugin-local-electron in your forge.config.js to point to your local Electron build output directory. This is useful for testing changes in Electron itself against your application. ```javascript // forge.config.js module.exports = { plugins: [ { name: '@electron-forge/plugin-local-electron', config: { electronPath: '/Users/me/projects/electron/out/Testing' } } ] }; ``` -------------------------------- ### Run Electron Forge Tests Source: https://github.com/electron/forge/blob/main/CONTRIBUTING.md Executes all tests within the Electron Forge repository. Some tests may take a significant amount of time to complete. ```bash yarn test ``` -------------------------------- ### Publish npm Packages Source: https://github.com/electron/forge/blob/main/CONTRIBUTING.md Publish all @electron-forge/ packages to npm using the Lerna script. This script automatically handles version bumping based on Conventional Commits. ```bash yarn lerna:publish ``` -------------------------------- ### Dry Run npm Publish Source: https://github.com/electron/forge/blob/main/CONTRIBUTING.md Perform a dry run of the npm publish command to verify the publish configuration without actually publishing the package. This is recommended before a manual publish. ```bash npm publish --dry-run ``` -------------------------------- ### Configure S3 Publisher in forge.config.js Source: https://github.com/electron/forge/blob/main/packages/publisher/s3/README.md Configure the S3 publisher in your forge.config.js file, specifying the bucket name and public access settings. ```javascript module.exports = { // ... publishers: [ { name: '@electron-forge/publisher-s3', config: { bucket: 'my-bucket', public: true } } ] }; ``` -------------------------------- ### Electron Forge Preload Launcher Script Source: https://github.com/electron/forge/wiki/Using-'preload'-scripts This script is required for Electron Forge to initialize electron-compile before your actual preload script executes. It must be referenced in the BrowserWindow's webPreferences. ```js // preload-launcher.js const { remote } = require('electron'); require('electron-compile/lib/initialize-renderer').initializeRendererProcess(remote.getGlobal('globalCompilerHost').readOnlyMode); require('path/to/real/preload'); ``` -------------------------------- ### Configure Deb Package Options Source: https://github.com/electron/forge/blob/main/packages/maker/deb/README.md Configure the deb maker with specific options such as maintainer, homepage, and icon path. This configuration is part of the Forge build process. ```javascript { name: '@electron-forge/maker-deb', config: { options: { maintainer: 'The Forgers', homepage: 'https://example.com', icon: 'path/to/icon.svg' } } } ``` -------------------------------- ### Clean Untracked Files Source: https://github.com/electron/forge/blob/main/CONTRIBUTING.md Remove any untracked files and directories from your local checkout to ensure a clean state. ```bash git clean -fdx ``` -------------------------------- ### Configure Fuses Plugin in Forge Source: https://github.com/electron/forge/blob/main/packages/plugin/fuses/README.md Add the FusesPlugin to your forge.config.js file, specifying the fuse version and options. ```javascript // forge.config.js const { FusesPlugin } = require('@electron-forge/plugin-fuses'); const { FuseV1Options, FuseVersion } = require('@electron/fuses'); const forgeConfig = { plugins: [ new FusesPlugin({ version: FuseVersion.V1, [FuseV1Options.RunAsNode]: false // ...any other options supported by @electron/fuses }) ] }; module.exports = forgeConfig; ``` -------------------------------- ### Configure Auto Unpack Natives Plugin Source: https://github.com/electron/forge/blob/main/packages/plugin/auto-unpack-natives/README.md Add this plugin to your forge.config.js to automatically unpack native Node modules. This is useful for reducing loading times and disk consumption. ```javascript // forge.config.js module.exports = { plugins: [ { name: '@electron-forge/plugin-auto-unpack-natives', config: {} } ] }; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.