Skip to content

Instantly share code, notes, and snippets.

@kyleparisi
Last active February 14, 2017 16:46
Show Gist options
  • Save kyleparisi/75079bcecf4cde767360ec6c06a64c0e to your computer and use it in GitHub Desktop.
Save kyleparisi/75079bcecf4cde767360ec6c06a64c0e to your computer and use it in GitHub Desktop.
Electron starter
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
We are using node <script>document.write(process.versions.node)</script>,
Chrome <script>document.write(process.versions.chrome)</script>,
and Electron <script>document.write(process.versions.electron)</script>.
</body>
</html>
const { app, BrowserWindow } = require("electron");
const path = require("path");
const url = require("url");
let win;
function createWindow() {
win = new BrowserWindow({ width: 800, height: 600 });
win.loadURL(
url.format({
pathname: path.join(__dirname, "index.html"),
protocol: "file:",
slashes: true
})
);
win.webContents.openDevTools();
win.on("closed", () => {
win = null;
});
}
app.on("ready", createWindow);
app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
});
app.on("activate", () => {
if (win === null) {
createWindow();
}
});
{
"name": "your-app",
"version": "0.1.0",
"description": "A minimal Electron application",
"main": "main.js",
"scripts": {
"start": "electron ."
},
"dependencies": {
"electron": "^1.4.15"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment