I need to open a second electron browserWindow in an Electron-React-Typescript app which I’m building using Electron-Forge,
and I tried to configure in forge.config.js two different renderer processes:
/* eslint-disable @typescript-eslint/no-var-requires */
// Forge Configuration
const path = require('path');
const rootDir = process.cwd();
module.exports = {
// Packager Config
packagerConfig: {
// Create asar archive for main, renderer process files
asar: true,
},
// Forge Makers
makers: [
{
// Squirrel.Windows is a no-prompt, no-hassle, no-admin method of installing
// Windows applications and is therefore the most user friendly you can get.
name: '@electron-forge/maker-squirrel',
config: {
name: 'trial_ipc_2020',
},
},
{
// The Zip target builds basic .zip files containing your packaged application.
// There are no platform specific dependencies for using this maker and it will run on any platform.
name: '@electron-forge/maker-zip',
platforms: ['darwin'],
},
{
// The deb target builds .deb packages, which are the standard package format for Debian-based
// Linux distributions such as Ubuntu.
name: '@electron-forge/maker-deb',
config: {},
},
{
// The RPM target builds .rpm files, which is the standard package format for
// RedHat-based Linux distributions such as Fedora.
name: '@electron-forge/maker-rpm',
config: {},
},
],
// Forge Plugins
plugins: [
[
// The Webpack plugin allows you to use standard Webpack tooling to compile both your main process code
// and your renderer process code, with built in support for Hot Module Reloading in the renderer
// process and support for multiple renderers.
'@electron-forge/plugin-webpack',
{
// Main process webpack configuration
mainConfig: path.join(rootDir, 'tools/webpack/webpack.main.js'),
// Renderer process webpack configuration
renderer: {
// Configuration file path
config: path.join(rootDir, 'tools/webpack/webpack.renderer.js'),
// Entrypoints of the application
entryPoints: [
{
// React Hot Module Replacement (HMR)
rhmr: 'react-hot-loader/patch',
// HTML index file template
html: path.join(rootDir, 'src/index.html'),
// Renderer
// https://www.electronjs.org/docs/tutorial/quick-start#main-and-renderer-processes
// https://github.com/electron-userland/electron-webpack/issues/47
//js: path.join(rootDir, 'src/renderer.ts'),
js: path.join(rootDir, ['src/renderer.ts', 'src/renderer-2.ts']),
// Main Window
name: 'main_window',
// Preload
preload: {
js: path.join(rootDir, 'src/preload.ts'),
},
},
],
},
},
],
],
};
Got this error:
(base) marco@pc01:~/webMatters/electronMatters/trial-ipc$ yarn start
yarn run v1.22.5
$ cross-env NODE_ENV=development electron-forge start
✔ Checking your system
✔ Locating Application
Failed to load: /home/marco/webMatters/electronMatters/trial-ipc/tools/forge/forge.config.js
An unhandled rejection has occurred inside Forge:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Array
at validateString (internal/validators.js:121:11)
at Object.join (path.js:1039:7)
at Object.<anonymous> (/home/marco/webMatters/electronMatters/trial-ipc/tools/forge/forge.config.js:66:24)
So… I have two questions:
is it feasible to open two browserWindow using electron-forge as tool for creating and managing the electron app?
And how to properly do it?
Looking forward to your kind help
2 posts - 2 participants
Read full topic