Use webpack-dev-server

This commit is contained in:
Yuya Ochiai
2017-03-05 00:27:40 +09:00
parent ae1c079b95
commit 6f4010edf2
6 changed files with 28 additions and 18 deletions

View File

@@ -11,6 +11,7 @@ const {
systemPreferences,
session
} = require('electron');
const isDev = require('electron-is-dev');
const AutoLaunch = require('auto-launch');
@@ -489,7 +490,11 @@ app.on('ready', () => {
}
// and load the index.html of the app.
mainWindow.loadURL('file://' + __dirname + '/browser/index.html');
if (isDev) {
mainWindow.loadURL('http://localhost:8080/browser/index.html');
} else {
mainWindow.loadURL('file://' + __dirname + '/browser/index.html');
}
// Set application menu
ipcMain.on('update-menu', (event, configData) => {
@@ -571,18 +576,4 @@ app.on('ready', () => {
// when you should delete the corresponding element.
mainWindow = null;
});
// Deny drag&drop navigation in mainWindow.
// Drag&drop is allowed in webview of index.html.
mainWindow.webContents.on('will-navigate', (event, url) => {
var dirname = __dirname;
if (process.platform === 'win32') {
dirname = '/' + dirname.replace(/\\/g, '/');
}
var index = url.indexOf('file://' + dirname);
if (index !== 0) {
event.preventDefault();
}
});
});