The forge.config.ts file defines the build and packaging configuration for the Electron application. It utilizes @electron-forge/plugin-vite to manage the build process for the main, preload, and renderer processes, and @electron-forge/plugin-fuses to apply security hardening via Electron Fuses.
Key configuration areas include:
- Makers: Defines output formats like Squirrel (Windows), ZIP (macOS), RPM, and DEB (Linux).
- PackagerConfig: Configures the underlying Electron packager, such as enabling
asar. - Plugins: Integrates Vite for bundling and Fuses for security.
- Publishers: Configures automated release workflows, such as publishing drafts to GitHub.
import { ForgeConfig } from "@electron-forge/shared-types";
import { VitePlugin } from "@electron-forge/plugin-vite";
import { FusesPlugin } from "@electron-forge/plugin-fuses";
const config: ForgeConfig = {
makers: [
new MakerSquirrel({}),
new MakerZIP({}, ["darwin"]),
new MakerRpm({}),
new MakerDeb({}),
],
packagerConfig: {
asar: true,
},
plugins: [
new VitePlugin({
build: [
{ config: "vite.main.config.mts", entry: "src/main.ts", target: "main" },
{ config: "vite.preload.config.mts", entry: "src/preload.ts", target: "preload" },
],
renderer: [
{ config: "vite.renderer.config.mts", name: "main_window" },
],
}),
new FusesPlugin({
version: FuseVersion.V1,
[FuseV1Options.RunAsNode]: false,
[FuseV1Options.EnableCookieEncryption]: true,
// ... other options
}),
],
publishers: [
{
name: "@electron-forge/publisher-github",
config: {
draft: true,
repository: { name: "electron-shadcn", owner: "LuanRoger" },
},
},
],
};
export default config;