|
1 |
| -import { app, BrowserWindow, ipcMain } from 'electron'; |
| 1 | +import { app, BrowserWindow, ipcMain, session } from 'electron'; |
2 | 2 | import './routes/dashboard';
|
3 | 3 | import { clearGuestSettings } from './routes/dashboard';
|
4 | 4 | import './routes/data';
|
5 | 5 | import './routes/cloudbased';
|
6 | 6 | import path from 'path';
|
| 7 | +import installExtension, { REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS } from 'electron-devtools-installer' |
7 | 8 |
|
8 | 9 | // Declare variable to be used as the application window
|
9 | 10 | let win: Electron.BrowserWindow;
|
10 | 11 |
|
11 | 12 | app.commandLine.appendSwitch('remote-debugging-port', '9222');
|
12 | 13 |
|
| 14 | +// Path to reactDevTools |
| 15 | +const reactDevToolsPath = path.resolve(__dirname, '../node_modules/react-devtools'); |
| 16 | + |
13 | 17 | /**
|
14 | 18 | * @desc createWindow sets up the environment of the window (dimensions, port, initial settings)
|
15 | 19 | */
|
@@ -56,9 +60,36 @@ const createWindow = () => {
|
56 | 60 | });
|
57 | 61 | };
|
58 | 62 |
|
| 63 | +const addDevTools = async () => { |
| 64 | + // await installExtension(REACT_DEVELOPER_TOOLS, { loadExtensionOptions: { allowFileAccess: true }}) |
| 65 | + // .then((name) => console.log(`Added Extension: ${name}`)) |
| 66 | + // .catch((err) => console.log('An error occurred: ', err)); |
| 67 | + // await installExtension(reactDevToolsPath) |
| 68 | + // .then((name) => console.log(`Added Extension: ${name}`)) |
| 69 | + // .catch((err) => console.log('An error occurred: ', err)); |
| 70 | + |
| 71 | + await installExtension(REDUX_DEVTOOLS) |
| 72 | + .then((name) => console.log(`Added Extension: ${name}`)) |
| 73 | + .catch((err) => console.log('An error occurred: ', err)); |
| 74 | + |
| 75 | + await session.defaultSession.loadExtension(reactDevToolsPath); |
| 76 | +}; |
| 77 | + |
| 78 | +app.whenReady().then(async () => { |
| 79 | + await addDevTools(); |
| 80 | + |
| 81 | + // await session.defaultSession.loadExtension(reactDevToolsPath); |
| 82 | +}); |
59 | 83 | // Invoke the createWindow function when Electron application loads
|
60 | 84 | app.on('ready', createWindow);
|
61 | 85 |
|
| 86 | +// Loads reactDevTools extension |
| 87 | +// app.whenReady().then(async () => { |
| 88 | +// console.log(reactDevToolsPath); |
| 89 | +// await session.defaultSession.loadExtension(reactDevToolsPath); |
| 90 | +// console.log({reactDevToolsPath}) |
| 91 | +// }); |
| 92 | + |
62 | 93 | // Quits application when all windows are closed
|
63 | 94 | app.on('window-all-closed', () => {
|
64 | 95 | app.quit();
|
|
0 commit comments