File tree 2 files changed +16
-12
lines changed
2 files changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,13 @@ const {app} = electron;
5
5
// Module to create native browser window.
6
6
const { BrowserWindow} = electron ;
7
7
8
- let win ;
8
+ let win , serve ;
9
+ const args = process . argv . slice ( 1 ) ;
10
+ serve = args . some ( val => val === "--serve" ) ;
11
+
12
+ if ( serve ) {
13
+ require ( 'electron-reload' ) ( __dirname + '/dist' ) ;
14
+ }
9
15
10
16
function createWindow ( ) {
11
17
@@ -20,20 +26,17 @@ function createWindow() {
20
26
height : size . height
21
27
} ) ;
22
28
23
- let url = 'file://' + __dirname + '/index.html' ;
24
- let Args = process . argv . slice ( 1 ) ;
25
-
26
- Args . forEach ( function ( val ) {
27
- if ( val === "--serve" ) {
28
- url = 'http://localhost:4200'
29
- }
30
- } ) ;
29
+ let url = serve ?
30
+ 'file://' + __dirname + '/dist/index.html' :
31
+ 'file://' + __dirname + '/index.html' ;
31
32
32
33
// and load the index.html of the app.
33
34
win . loadURL ( url ) ;
34
35
35
36
// Open the DevTools.
36
- win . webContents . openDevTools ( ) ;
37
+ if ( serve ) {
38
+ win . webContents . openDevTools ( ) ;
39
+ }
37
40
38
41
// Emitted when the window is closed.
39
42
win . on ( 'closed' , ( ) => {
@@ -64,4 +67,4 @@ app.on('activate', () => {
64
67
if ( win === null ) {
65
68
createWindow ( ) ;
66
69
}
67
- } ) ;
70
+ } ) ;
Original file line number Diff line number Diff line change 17
17
"private" : true ,
18
18
"scripts" : {
19
19
"ng" : " ng" ,
20
- "start" : " webpack-dev-server --port=4200 " ,
20
+ "start" : " webpack --watch " ,
21
21
"test" : " karma start ./karma.conf.js" ,
22
22
"lint" : " ng lint" ,
23
23
"e2e" : " protractor ./protractor.conf.js" ,
57
57
"electron" : " ~1.6.2" ,
58
58
"electron-packager" : " ~8.6.0" ,
59
59
"electron-prebuilt" : " ~1.4.13" ,
60
+ "electron-reload" : " ^1.1.0" ,
60
61
"exports-loader" : " ~0.6.3" ,
61
62
"file-loader" : " ~0.10.0" ,
62
63
"istanbul-instrumenter-loader" : " ~2.0.0" ,
You can’t perform that action at this time.
0 commit comments