backsplash-app
Version:
An AI powered wallpaper app.
132 lines (126 loc) • 4.42 kB
text/typescript
import path from "path";
import { FuseV1Options, FuseVersion } from "@electron/fuses";
import { MakerSquirrel } from "@electron-forge/maker-squirrel";
import { MakerZIP } from "@electron-forge/maker-zip";
import { MakerDMG } from "@electron-forge/maker-dmg";
import { MakerDeb } from "@electron-forge/maker-deb";
import { FusesPlugin } from "@electron-forge/plugin-fuses";
import { VitePlugin } from "@electron-forge/plugin-vite";
import type { ForgeConfig } from "@electron-forge/shared-types";
import { productName } from "./package.json";
const rootDir = process.cwd();
const config: ForgeConfig = {
packagerConfig: {
// Create asar archive for main, renderer process files
// We need to unpack the wallpaper package because it contains native binaries
// otherwise this works in development but not in production
asar: {
unpack: "node_modules/wallpaper/**/*",
},
// Set executable name
executableName: productName,
// Set application copyright
appCopyright: `Copyright (C) ${new Date().getFullYear()} James Darby`,
// Set application icon
icon: path.resolve(rootDir, "assets/icons/icon"),
// Explicitly include assets directory and wallpaper binaries
extraResource: [
"assets",
"node_modules/wallpaper/source/macos-wallpaper",
"node_modules/wallpaper/source/windows-wallpaper-x86-64.exe",
],
// Ignore files/directories that don't need to be packaged
ignore: [/^\/out\//, /^\/\.vscode\//, /^\/\.git\//, /^\/\.github\//, /^\/scripts\//, /\.map$/],
// For a menubar app
...(process.platform === "darwin" && {
appCategoryType: "public.app-category.utilities",
hardenedRuntime: true,
gatekeeperAssess: false,
osxSign: {
identity: process.env.APPLE_DEVELOPER_IDENTITY,
optionsForFile: () => ({
entitlements: "entitlements.plist",
}),
},
osxNotarize: {
appleId: process.env.APPLE_ID,
appleIdPassword: process.env.APPLE_ID_PASSWORD,
teamId: process.env.APPLE_TEAM_ID,
},
}),
protocols: [
{
name: "Backsplash Protocol",
schemes: ["backsplash"],
},
],
},
rebuildConfig: {},
makers: [
new MakerSquirrel({
name: productName,
setupIcon: path.resolve(rootDir, "assets/icons/icon.ico"),
// Add auto-updates configuration for Squirrel.Windows
remoteReleases: process.env.S3_BUCKET ? `https://${process.env.S3_BUCKET}.s3.amazonaws.com/win32/` : undefined,
}),
new MakerDMG({
name: productName,
background: "./assets/dmg-background.png",
format: "ULFO",
}),
new MakerZIP(
{
macUpdateManifestBaseUrl: process.env.S3_BUCKET
? `https://${process.env.S3_BUCKET}.s3.amazonaws.com/darwin/${process.arch}`
: undefined,
},
["darwin", "debian"],
),
new MakerDeb({}),
],
publishers: [
{
name: "@electron-forge/publisher-s3",
config: {
bucket: process.env.S3_BUCKET || "backsplash-releases",
region: process.env.S3_REGION || "us-east-1",
public: false,
},
},
],
plugins: [
new VitePlugin({
// `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 `build.lib.entry` in the corresponding file of `config`.
entry: "src/main.ts",
config: "config/vite.main.config.ts",
},
{
entry: "src/preload.ts",
config: "config/vite.preload.config.ts",
},
],
renderer: [
{
name: "main_window",
config: "config/vite.renderer.config.ts",
},
],
}),
// Fuses are used to enable/disable various Electron functionality
// at package time, before code signing the application
new FusesPlugin({
version: FuseVersion.V1,
[FuseV1Options.RunAsNode]: false,
[FuseV1Options.EnableCookieEncryption]: true,
[FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false,
[FuseV1Options.EnableNodeCliInspectArguments]: false,
[FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
[FuseV1Options.OnlyLoadAppFromAsar]: true,
}),
],
};
export default config;