Added electron-forge to project.

This commit is contained in:
Patrick Fic
2020-10-13 10:21:46 -07:00
parent 845ed58617
commit 0715b20e4c
3 changed files with 20865 additions and 9 deletions

View File

@@ -3,6 +3,20 @@ const path = require("path");
const { app, BrowserWindow } = require("electron");
const isDev = require("electron-is-dev");
// Conditionally include the dev tools installer to load React Dev Tools
let installExtension, REACT_DEVELOPER_TOOLS; // NEW!
if (isDev) {
const devTools = require("electron-devtools-installer");
installExtension = devTools.default;
REACT_DEVELOPER_TOOLS = devTools.REACT_DEVELOPER_TOOLS;
} // NEW!
// Handle creating/removing shortcuts on Windows when installing/uninstalling
if (require("electron-squirrel-startup")) {
app.quit();
} // NEW!
function createWindow() {
// Create the browser window.
const win = new BrowserWindow({
@@ -30,7 +44,16 @@ function createWindow() {
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.whenReady().then(createWindow);
app.whenReady().then(() => {
console.log("Ready to launch the app!");
createWindow();
if (isDev) {
installExtension(REACT_DEVELOPER_TOOLS)
.then((name) => console.log(`Added Extension: ${name}`))
.catch((error) => console.log(`An error occurred: , ${error}`));
}
});
// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits