import { app , BrowserWindow } from 'electron' ; import * as path from 'path' ; import * as url from 'url' ; import { staticPath } from './utils/staticPath' ; const CRA_DEV_URL = 'http://localhost:3000' ; let mainWindow ; const createMainWindow = ( ) => { mainWindow = new BrowserWindow ( { width : 800 , height : 600 } ) ; mainWindow . loadURL ( process . env . NODE_ENV === 'production' ? url . format ( { pathname : path . join ( staticPath , 'build' , 'index.html' ) , protocol : 'file:' , slashes : true } ) : CRA_DEV_URL ) ; mainWindow . on ( 'closed' , ( ) => { mainWindow = undefined ; } ) ; } ; app . on ( 'window-all-closed' , ( ) => { if ( process . platform !== 'darwin' ) { app . quit ( ) ; } } ) ; app . on ( 'activate' , ( ) => { if ( ! mainWindow ) { createMainWindow ( ) ; } } ) ; app . on ( 'ready' , ( ) => { createMainWindow ( ) ; } ) ;