Last active
October 8, 2019 06:19
-
-
Save Pipe-Runner/449da7077b82dab5111bf17c870015d3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const electron = require('electron'); | |
const path = require('path'); | |
const url = require('url'); | |
const { app } = electron; | |
const { BrowserWindow } = electron; | |
let mainWindow; | |
function createWindow() { | |
const startUrl = process.env.DEV | |
? 'http://localhost:3000' | |
: url.format({ | |
pathname: path.join(__dirname, '/../build/index.html'), | |
protocol: 'file:', | |
slashes: true, | |
}); | |
mainWindow = new BrowserWindow(); | |
mainWindow.loadURL(startUrl); | |
process.env.DEV && mainWindow.webContents.openDevTools(); | |
mainWindow.on('closed', function() { | |
mainWindow = null; | |
}); | |
} | |
app.on('ready', createWindow); | |
app.on('window-all-closed', () => { | |
if (process.platform !== 'darwin') { | |
app.quit(); | |
} | |
}); | |
app.on('activate', () => { | |
if (mainWindow === null) { | |
createWindow(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment