Skip to content

Instantly share code, notes, and snippets.

@GoodNovember
Last active February 25, 2019 17:45
Show Gist options
  • Save GoodNovember/4e37d7d1a9add2faeb0d97592bd2372e to your computer and use it in GitHub Desktop.
Save GoodNovember/4e37d7d1a9add2faeb0d97592bd2372e to your computer and use it in GitHub Desktop.
Electron Boilerplate Without Comments
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src https://*; child-src 'none';">
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
// SEE: https://github.com/electron/electron-quick-start
const {app, BrowserWindow} = require('electron')
const path = require('path')
let mainWindow
function createWindow () {
mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
contextIsolation: false,
nodeIntegration: true,
preload: path.join(__dirname, 'preload.js')
}
})
mainWindow.loadFile('index.html')
mainWindow.webContents.openDevTools()
mainWindow.on('closed', function () {
mainWindow = null
})
}
app.on('ready', createWindow)
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', function () {
if (mainWindow === null) {
createWindow()
}
})
console.log('Hello from Preload!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment