Skip to content

Commit

Permalink
live reload on disk
Browse files Browse the repository at this point in the history
  • Loading branch information
danieloprado authored and maximegris committed Apr 12, 2017
1 parent a172df9 commit 7bb2f8b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
25 changes: 14 additions & 11 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ const {app} = electron;
// Module to create native browser window.
const {BrowserWindow} = electron;

let win;
let win, serve;
const args = process.argv.slice(1);
serve = args.some(val => val === "--serve");

if (serve) {
require('electron-reload')(__dirname + '/dist');
}

function createWindow() {

Expand All @@ -20,20 +26,17 @@ function createWindow() {
height: size.height
});

let url = 'file://' + __dirname + '/index.html';
let Args = process.argv.slice(1);

Args.forEach(function (val) {
if (val === "--serve") {
url = 'http://localhost:4200'
}
});
let url = serve ?
'file://' + __dirname + '/dist/index.html':
'file://' + __dirname + '/index.html';

// and load the index.html of the app.
win.loadURL(url);

// Open the DevTools.
win.webContents.openDevTools();
if (serve) {
win.webContents.openDevTools();
}

// Emitted when the window is closed.
win.on('closed', () => {
Expand Down Expand Up @@ -64,4 +67,4 @@ app.on('activate', () => {
if (win === null) {
createWindow();
}
});
});
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"private": true,
"scripts": {
"ng": "ng",
"start": "webpack-dev-server --port=4200",
"start": "webpack --watch",
"test": "karma start ./karma.conf.js",
"lint": "ng lint",
"e2e": "protractor ./protractor.conf.js",
Expand Down Expand Up @@ -57,6 +57,7 @@
"electron": "~1.6.2",
"electron-packager": "~8.6.0",
"electron-prebuilt": "~1.4.13",
"electron-reload": "^1.1.0",
"exports-loader": "~0.6.3",
"file-loader": "~0.10.0",
"istanbul-instrumenter-loader": "~2.0.0",
Expand Down

0 comments on commit 7bb2f8b

Please sign in to comment.