| 9 | |
| 10 | // Create the native browser window. |
| 11 | function createWindow() { |
| 12 | const mainWindow = new BrowserWindow({ |
| 13 | width: 950, |
| 14 | height: 700, |
| 15 | // Set the path of an additional "preload" script that can be used to |
| 16 | // communicate between node-land and browser-land. |
| 17 | titleBarStyle: 'hidden', |
| 18 | titleBarOverlay: { |
| 19 | color: 'rgb(37,37,38)', |
| 20 | symbolColor: '#74b1be' |
| 21 | }, |
| 22 | webPreferences: { |
| 23 | nodeIntegration: true, |
| 24 | enableRemoteModule: true, |
| 25 | contextIsolation: false, |
| 26 | preload: path.join(__dirname, "preload.js"), |
| 27 | }, |
| 28 | }); |
| 29 | |
| 30 | // In production, set the initial browser path to the local bundle generated |
| 31 | // by the Create React App build process. |
| 32 | // In development, set it to localhost to allow live/hot-reloading. |
| 33 | const appURL = app.isPackaged |
| 34 | ? url.format({ |
| 35 | pathname: path.join(__dirname, "index.html"), |
| 36 | protocol: "file:", |
| 37 | slashes: true, |
| 38 | }) |
| 39 | : "http://localhost:3000"; |
| 40 | mainWindow.loadURL(appURL); |
| 41 | |
| 42 | // Automatically open Chrome's DevTools in development mode. |
| 43 | if (!app.isPackaged) { |
| 44 | mainWindow.webContents.openDevTools({ mode: "detach" }); |
| 45 | } |
| 46 | |
| 47 | } |
| 48 | |
| 49 | // Setup a local proxy to adjust the paths of requested files when loading |
| 50 | // them from the local production bundle (e.g.: local fonts, etc...). |