mirror of
https://github.com/colanode/colanode.git
synced 2025-12-29 00:25:03 +01:00
141 lines
4.2 KiB
TypeScript
141 lines
4.2 KiB
TypeScript
import { FuseV1Options, FuseVersion } from '@electron/fuses';
|
|
import { MakerSquirrel } from '@electron-forge/maker-squirrel';
|
|
import { MakerDMG } from '@electron-forge/maker-dmg';
|
|
import { FusesPlugin } from '@electron-forge/plugin-fuses';
|
|
import { VitePlugin } from '@electron-forge/plugin-vite';
|
|
import type { ForgeConfig } from '@electron-forge/shared-types';
|
|
|
|
import fs from 'fs/promises';
|
|
|
|
const config: ForgeConfig = {
|
|
packagerConfig: {
|
|
name: 'Colanode',
|
|
executableName: process.platform === 'linux' ? 'colanode' : 'Colanode',
|
|
icon: 'assets/colanode_logo_black',
|
|
appBundleId: 'com.colanode.desktop',
|
|
...(process.platform === 'win32' && {
|
|
certificateFile: process.env.CERTIFICATE_PATH,
|
|
certificatePassword: process.env.CERTIFICATE_PASSWORD,
|
|
}),
|
|
asar: true,
|
|
prune: true,
|
|
ignore: (path) => {
|
|
if (!path) {
|
|
return false;
|
|
}
|
|
|
|
if (path === '/package.json') {
|
|
return false;
|
|
}
|
|
|
|
if (path.startsWith('/node_modules')) {
|
|
return false;
|
|
}
|
|
|
|
if (path.startsWith('/.vite')) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
},
|
|
extraResource: ['assets'],
|
|
},
|
|
rebuildConfig: {},
|
|
makers: [
|
|
new MakerSquirrel({
|
|
name: 'Colanode',
|
|
...(process.platform === 'win32' && {
|
|
certificateFile: process.env.CERTIFICATE_PATH,
|
|
certificatePassword: process.env.CERTIFICATE_PASSWORD,
|
|
}),
|
|
}),
|
|
new MakerDMG({
|
|
name: 'Colanode',
|
|
appPath: '',
|
|
}),
|
|
],
|
|
publishers: [
|
|
{
|
|
name: '@electron-forge/publisher-github',
|
|
config: {
|
|
repository: {
|
|
owner: 'colanode',
|
|
name: 'colanode',
|
|
},
|
|
// Publishing options:
|
|
// draft=true creates private release for review,
|
|
// prerelease=true marks as beta, false=stable/production
|
|
prerelease: false,
|
|
draft: true,
|
|
},
|
|
},
|
|
],
|
|
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: 'vite.main.config.ts',
|
|
target: 'main',
|
|
},
|
|
{
|
|
entry: 'src/preload.ts',
|
|
config: 'vite.preload.config.ts',
|
|
target: 'preload',
|
|
},
|
|
],
|
|
renderer: [
|
|
{
|
|
name: 'main_window',
|
|
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,
|
|
}),
|
|
],
|
|
hooks: {
|
|
prePackage: async () => {
|
|
// This is a temporary fix to be able to package the app
|
|
// in a monorepo setup. When packaging the app, vite checks only in
|
|
// the node_modules directory of the current package for dependencies needed in the main process.
|
|
// This is why we need to copy the node_modules directory from the root to the build directory.
|
|
|
|
// to be removed when forge supports monorepos
|
|
|
|
const srcNodeModules = '../../node_modules';
|
|
const destNodeModules = './node_modules';
|
|
|
|
// First clear the node_modules directory
|
|
await fs.rm(destNodeModules, { recursive: true, force: true });
|
|
|
|
// Ensure the destination directory exists
|
|
await fs.mkdir(destNodeModules, { recursive: true });
|
|
|
|
// Copy the entire node_modules directory recursively
|
|
await fs.cp(srcNodeModules, destNodeModules, {
|
|
recursive: true,
|
|
force: true,
|
|
});
|
|
},
|
|
postPackage: async () => {
|
|
// remove the node_modules directory
|
|
await fs.rm('./node_modules', { recursive: true, force: true });
|
|
},
|
|
},
|
|
};
|
|
|
|
export default config;
|