only import electron-devtools-installer in dev mode

This commit is contained in:
Christopher Willis-Ford 2018-10-31 15:57:04 -07:00
parent eff882c928
commit 4767897f4b

View file

@ -2,8 +2,6 @@ import {app, BrowserWindow} from 'electron';
import * as path from 'path'; import * as path from 'path';
import {format as formatUrl} from 'url'; import {format as formatUrl} from 'url';
import installExtension, {REACT_DEVELOPER_TOOLS} from 'electron-devtools-installer';
const isDevelopment = process.env.NODE_ENV !== 'production'; const isDevelopment = process.env.NODE_ENV !== 'production';
// global reference to mainWindow (necessary to prevent window from being garbage collected) // global reference to mainWindow (necessary to prevent window from being garbage collected)
@ -18,10 +16,13 @@ const createMainWindow = () => {
if (isDevelopment) { if (isDevelopment) {
window.webContents.openDevTools(); window.webContents.openDevTools();
installExtension(REACT_DEVELOPER_TOOLS); import('electron-devtools-installer').then(importedModule => {
// TODO: add logging package and bring back the lines below const {default: installExtension, REACT_DEVELOPER_TOOLS} = importedModule;
// .then(name => console.log(`Added Extension: ${name}`)) installExtension(REACT_DEVELOPER_TOOLS);
// .catch(err => console.log('An error occurred: ', err)); // TODO: add logging package and bring back the lines below
// .then(name => console.log(`Added Extension: ${name}`))
// .catch(err => console.log('An error occurred: ', err));
});
} }
if (isDevelopment) { if (isDevelopment) {