max-mapper / menubar

➖ high level way to create menubar desktop applications with electron
BSD 2-Clause "Simplified" License
6.64k stars 363 forks source link

Electron Forge x React with Menubar #430

Closed maxmandia closed 1 year ago

maxmandia commented 1 year ago

Description

I am trying to load the correct index file in the menubar options with a electron forge app set up with webpack and react. I'm not sure what path to use for the index. Any help would be appreciated.

const { app, BrowserWindow } = require("electron");
const path = require("path");
const { menubar } = require("menubar");

const mb = menubar({
  icon: "./src/assets/brain@4x.png",
  index: "file://" + path.join(__dirname, "src", "app.jsx"),
  preloadWindow: true,
});

// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require("electron-squirrel-startup")) {
  app.quit();
}

app.on("window-all-closed", () => {
  if (process.platform !== "darwin") {
    app.quit();
  }
});

mb.on("ready", () => {
  console.log("app is ready");
  // your app code here
});

Steps to Reproduce the Problem

  1. ...
  2. ...
  3. ...

Expected Behaviour

Actual Behaviour

Specifications

Other information

maxmandia commented 1 year ago

Here's the fix:

const mb = menubar({
  icon: "./src/assets/brain@4x.png",
  index: MAIN_WINDOW_WEBPACK_ENTRY,
  preloadWindow: true,
  showDockIcon: false,
  browserWindow: {
    width: 750,
    height: 500,
    x: 10000,
    alwaysOnTop: true,
  },
});