live reload on disk
This commit is contained in:
committed by
Maxime GRIS
parent
a172df94d9
commit
7bb2f8b20a
21
main.js
21
main.js
@@ -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() {
|
||||
|
||||
@@ -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.
|
||||
if (serve) {
|
||||
win.webContents.openDevTools();
|
||||
}
|
||||
|
||||
// Emitted when the window is closed.
|
||||
win.on('closed', () => {
|
||||
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user