Skip to content

Instantly share code, notes, and snippets.

@shalkam
Created May 23, 2017 07:13
Show Gist options
  • Save shalkam/c1575814a62c0e6d22d8139dd1c7d414 to your computer and use it in GitHub Desktop.
Save shalkam/c1575814a62c0e6d22d8139dd1c7d414 to your computer and use it in GitHub Desktop.
Load url into electron without caching
import { app, BrowserWindow, Menu, shell } from 'electron';
import Server from './server/server.js';
let menu;
let template;
let mainWindow = null;
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit();
});
app.on('ready', () => {
Server.init();
mainWindow = new BrowserWindow({ show: false, width: 1024, height: 728 });
Server.on('server.loaded', port => {
mainWindow.loadURL(`http://localhost:${port}`, { extraHeaders: 'pragma: no-cache\n' });
mainWindow.webContents.send('loaded.server', port);
});
mainWindow.webContents.on('did-finish-load', () => {
mainWindow.show();
mainWindow.focus();
mainWindow.webContents.send('app.started');
});
mainWindow.on('closed', () => {
mainWindow = null;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment