Hot reload using Electron and Angular












1















I'm using Angular and Electron for my app.
I'm looking for a way to enable hot reload...
When I run my yarn run electron (scripts : "electron": "ng build --base-href ./ && electron ."), if I save a change, my app isn't reloading.
Here is my main.js file :



const { app, BrowserWindow } = require("electron");
const path = require("path");
const url = require("url");

let win;

function createWindow() {
win = new BrowserWindow({ width: 800, height: 600 });

// load the dist folder from Angular
win.loadURL(
url.format({
pathname: path.join(__dirname, `/dist/index.html`),
protocol: "file:",
slashes: true
})
);

// The following is optional and will open the DevTools:
// win.webContents.openDevTools()

win.on("closed", () => {
win = null;
});
}

app.on("ready", createWindow);

// on macOS, closing the window doesn't quit the app
app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
});

// initialize the app's main window
app.on("activate", () => {
if (win === null) {
createWindow();
}
});


I tried to include require('electron-reload')(__dirname); in the main.js file but nothing changed










share|improve this question

























  • "change a save" did you mean "save a change"?

    – Tiny Giant
    Nov 23 '18 at 22:30











  • Also, are you trying to do a hard-reset (restart the electron main.js process) or a soft-reset (restart the BrowserWindow renderer processes)

    – Tiny Giant
    Nov 23 '18 at 22:34











  • Yes sorry I edited. I don't really know, i'm new to electron, i'm trying to hot reload as Angular do.. I guess it's a soft reset, isn't it ?

    – Clément Drouin
    Nov 23 '18 at 22:37











  • Well are you expecting changes to your main.js file to cause a reload? If you are that would require a hard-reset. If you aren't worried about changes to your main.js file (i.e. you're okay with manually restarting the app by killing it then starting it again) then you can do with a soft-reset

    – Tiny Giant
    Nov 23 '18 at 23:05






  • 1





    I'll write up an example.

    – Tiny Giant
    Nov 23 '18 at 23:15
















1















I'm using Angular and Electron for my app.
I'm looking for a way to enable hot reload...
When I run my yarn run electron (scripts : "electron": "ng build --base-href ./ && electron ."), if I save a change, my app isn't reloading.
Here is my main.js file :



const { app, BrowserWindow } = require("electron");
const path = require("path");
const url = require("url");

let win;

function createWindow() {
win = new BrowserWindow({ width: 800, height: 600 });

// load the dist folder from Angular
win.loadURL(
url.format({
pathname: path.join(__dirname, `/dist/index.html`),
protocol: "file:",
slashes: true
})
);

// The following is optional and will open the DevTools:
// win.webContents.openDevTools()

win.on("closed", () => {
win = null;
});
}

app.on("ready", createWindow);

// on macOS, closing the window doesn't quit the app
app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
});

// initialize the app's main window
app.on("activate", () => {
if (win === null) {
createWindow();
}
});


I tried to include require('electron-reload')(__dirname); in the main.js file but nothing changed










share|improve this question

























  • "change a save" did you mean "save a change"?

    – Tiny Giant
    Nov 23 '18 at 22:30











  • Also, are you trying to do a hard-reset (restart the electron main.js process) or a soft-reset (restart the BrowserWindow renderer processes)

    – Tiny Giant
    Nov 23 '18 at 22:34











  • Yes sorry I edited. I don't really know, i'm new to electron, i'm trying to hot reload as Angular do.. I guess it's a soft reset, isn't it ?

    – Clément Drouin
    Nov 23 '18 at 22:37











  • Well are you expecting changes to your main.js file to cause a reload? If you are that would require a hard-reset. If you aren't worried about changes to your main.js file (i.e. you're okay with manually restarting the app by killing it then starting it again) then you can do with a soft-reset

    – Tiny Giant
    Nov 23 '18 at 23:05






  • 1





    I'll write up an example.

    – Tiny Giant
    Nov 23 '18 at 23:15














1












1








1








I'm using Angular and Electron for my app.
I'm looking for a way to enable hot reload...
When I run my yarn run electron (scripts : "electron": "ng build --base-href ./ && electron ."), if I save a change, my app isn't reloading.
Here is my main.js file :



const { app, BrowserWindow } = require("electron");
const path = require("path");
const url = require("url");

let win;

function createWindow() {
win = new BrowserWindow({ width: 800, height: 600 });

// load the dist folder from Angular
win.loadURL(
url.format({
pathname: path.join(__dirname, `/dist/index.html`),
protocol: "file:",
slashes: true
})
);

// The following is optional and will open the DevTools:
// win.webContents.openDevTools()

win.on("closed", () => {
win = null;
});
}

app.on("ready", createWindow);

// on macOS, closing the window doesn't quit the app
app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
});

// initialize the app's main window
app.on("activate", () => {
if (win === null) {
createWindow();
}
});


I tried to include require('electron-reload')(__dirname); in the main.js file but nothing changed










share|improve this question
















I'm using Angular and Electron for my app.
I'm looking for a way to enable hot reload...
When I run my yarn run electron (scripts : "electron": "ng build --base-href ./ && electron ."), if I save a change, my app isn't reloading.
Here is my main.js file :



const { app, BrowserWindow } = require("electron");
const path = require("path");
const url = require("url");

let win;

function createWindow() {
win = new BrowserWindow({ width: 800, height: 600 });

// load the dist folder from Angular
win.loadURL(
url.format({
pathname: path.join(__dirname, `/dist/index.html`),
protocol: "file:",
slashes: true
})
);

// The following is optional and will open the DevTools:
// win.webContents.openDevTools()

win.on("closed", () => {
win = null;
});
}

app.on("ready", createWindow);

// on macOS, closing the window doesn't quit the app
app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
});

// initialize the app's main window
app.on("activate", () => {
if (win === null) {
createWindow();
}
});


I tried to include require('electron-reload')(__dirname); in the main.js file but nothing changed







angular electron






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 22:36







Clément Drouin

















asked Nov 23 '18 at 22:27









Clément DrouinClément Drouin

12617




12617













  • "change a save" did you mean "save a change"?

    – Tiny Giant
    Nov 23 '18 at 22:30











  • Also, are you trying to do a hard-reset (restart the electron main.js process) or a soft-reset (restart the BrowserWindow renderer processes)

    – Tiny Giant
    Nov 23 '18 at 22:34











  • Yes sorry I edited. I don't really know, i'm new to electron, i'm trying to hot reload as Angular do.. I guess it's a soft reset, isn't it ?

    – Clément Drouin
    Nov 23 '18 at 22:37











  • Well are you expecting changes to your main.js file to cause a reload? If you are that would require a hard-reset. If you aren't worried about changes to your main.js file (i.e. you're okay with manually restarting the app by killing it then starting it again) then you can do with a soft-reset

    – Tiny Giant
    Nov 23 '18 at 23:05






  • 1





    I'll write up an example.

    – Tiny Giant
    Nov 23 '18 at 23:15



















  • "change a save" did you mean "save a change"?

    – Tiny Giant
    Nov 23 '18 at 22:30











  • Also, are you trying to do a hard-reset (restart the electron main.js process) or a soft-reset (restart the BrowserWindow renderer processes)

    – Tiny Giant
    Nov 23 '18 at 22:34











  • Yes sorry I edited. I don't really know, i'm new to electron, i'm trying to hot reload as Angular do.. I guess it's a soft reset, isn't it ?

    – Clément Drouin
    Nov 23 '18 at 22:37











  • Well are you expecting changes to your main.js file to cause a reload? If you are that would require a hard-reset. If you aren't worried about changes to your main.js file (i.e. you're okay with manually restarting the app by killing it then starting it again) then you can do with a soft-reset

    – Tiny Giant
    Nov 23 '18 at 23:05






  • 1





    I'll write up an example.

    – Tiny Giant
    Nov 23 '18 at 23:15

















"change a save" did you mean "save a change"?

– Tiny Giant
Nov 23 '18 at 22:30





"change a save" did you mean "save a change"?

– Tiny Giant
Nov 23 '18 at 22:30













Also, are you trying to do a hard-reset (restart the electron main.js process) or a soft-reset (restart the BrowserWindow renderer processes)

– Tiny Giant
Nov 23 '18 at 22:34





Also, are you trying to do a hard-reset (restart the electron main.js process) or a soft-reset (restart the BrowserWindow renderer processes)

– Tiny Giant
Nov 23 '18 at 22:34













Yes sorry I edited. I don't really know, i'm new to electron, i'm trying to hot reload as Angular do.. I guess it's a soft reset, isn't it ?

– Clément Drouin
Nov 23 '18 at 22:37





Yes sorry I edited. I don't really know, i'm new to electron, i'm trying to hot reload as Angular do.. I guess it's a soft reset, isn't it ?

– Clément Drouin
Nov 23 '18 at 22:37













Well are you expecting changes to your main.js file to cause a reload? If you are that would require a hard-reset. If you aren't worried about changes to your main.js file (i.e. you're okay with manually restarting the app by killing it then starting it again) then you can do with a soft-reset

– Tiny Giant
Nov 23 '18 at 23:05





Well are you expecting changes to your main.js file to cause a reload? If you are that would require a hard-reset. If you aren't worried about changes to your main.js file (i.e. you're okay with manually restarting the app by killing it then starting it again) then you can do with a soft-reset

– Tiny Giant
Nov 23 '18 at 23:05




1




1





I'll write up an example.

– Tiny Giant
Nov 23 '18 at 23:15





I'll write up an example.

– Tiny Giant
Nov 23 '18 at 23:15












3 Answers
3






active

oldest

votes


















1














electron-reload by default only reloads the WebContents of all open BrowserWindows when a file changes. If you want to restart Electron (i.e. if you want changes to the Electron main process file to reload the application), then what you're looking for is a "hard reset".



To do this you'll have to set the electron app path, like so:



require('electron-reload')(__dirname, {
electron: path.join(__dirname, 'node_modules/.bin/electron.cmd')
});


The documentation says that the path should be to ./node_modules/.bin/electron, but I've only been able to get it to work using ./node_modules/.bin/electron.cmd. This is apparently an issue with Windows machines, and supposedly pointing to the executable works on MacOS. This may also be the case on Linux systems.



The following should be all the files you need for a boilerplate example:



./main.js



const { app, BrowserWindow } = require('electron')
const path = require('path')
const url = require('url')

require('electron-reload')(__dirname, {
electron: path.join(__dirname, 'node_modules/.bin/electron.cmd')
});

let mainWindow = null

function main() {
mainWindow = new BrowserWindow()

mainWindow.loadURL(
url.format({
pathname: path.join(__dirname, '/dist/index.html'),
protocol: 'file:',
slashes: true
})
)

mainWindow.on('closed', () => {
mainWindow = null
})
}

app.on('ready', main)

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})

app.on('activate', () => {
if (mainWindow === null) {
main()
}
})


./index.html



<h1>Hello World!</h1>


./package.json



{
"name": "electron-hot-reload-boilerplate",
"version": "1.0.0",
"description": "An Electron Boilerplate demonstrating hot reloading",
"main": "main.js",
"scripts": {
"start": "electron ."
},
"repository": "https://github.com/link/to/your/repo",
"keywords": ,
"author": "You",
"license": "CC-BY-SA-3.0",
"dependencies": {
"electron": "^3.0.9",
"electron-reload": "^1.3.0"
}
}


Install with:



> npm install


Run with:



> npm start





share|improve this answer


























  • Thanks, I tried on Windows and when I save a change on my angular component, i got a white page...

    – Clément Drouin
    Nov 24 '18 at 15:00





















0














Isn't app.relaunch() the way to go to perform a "hard reset"?




app.relaunch([options])





  • options Object (optional)



    • args String


    • execPath String (optional)




Relaunches the app when current instance exits.



By default the new instance will use the same working directory and
command line arguments with current instance. When args is specified,
the args will be passed as command line arguments instead. When
execPath is specified, the execPath will be executed for relaunch
instead of current app.



Note that this method does not quit the app when executed, you have to
call app.quit or app.exit after calling app.relaunch to make the
app restart.







share|improve this answer
























  • The question askes how to use electron-reload which is a package that monitors files in a directory for changes and restarts the application when changes are made. app.relaunch is just a method to relaunch the app, it doesn't monitor any files. So no, this does not in any way answer the question.

    – Tiny Giant
    Nov 26 '18 at 16:20



















0














I found this : https://github.com/maximegris/angular-electron
It's an empty project template, using Electron and Angular.
Execute yarn start allow the hot reloading.
It's well written in the README.md !






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53453504%2fhot-reload-using-electron-and-angular%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    electron-reload by default only reloads the WebContents of all open BrowserWindows when a file changes. If you want to restart Electron (i.e. if you want changes to the Electron main process file to reload the application), then what you're looking for is a "hard reset".



    To do this you'll have to set the electron app path, like so:



    require('electron-reload')(__dirname, {
    electron: path.join(__dirname, 'node_modules/.bin/electron.cmd')
    });


    The documentation says that the path should be to ./node_modules/.bin/electron, but I've only been able to get it to work using ./node_modules/.bin/electron.cmd. This is apparently an issue with Windows machines, and supposedly pointing to the executable works on MacOS. This may also be the case on Linux systems.



    The following should be all the files you need for a boilerplate example:



    ./main.js



    const { app, BrowserWindow } = require('electron')
    const path = require('path')
    const url = require('url')

    require('electron-reload')(__dirname, {
    electron: path.join(__dirname, 'node_modules/.bin/electron.cmd')
    });

    let mainWindow = null

    function main() {
    mainWindow = new BrowserWindow()

    mainWindow.loadURL(
    url.format({
    pathname: path.join(__dirname, '/dist/index.html'),
    protocol: 'file:',
    slashes: true
    })
    )

    mainWindow.on('closed', () => {
    mainWindow = null
    })
    }

    app.on('ready', main)

    app.on('window-all-closed', () => {
    if (process.platform !== 'darwin') {
    app.quit()
    }
    })

    app.on('activate', () => {
    if (mainWindow === null) {
    main()
    }
    })


    ./index.html



    <h1>Hello World!</h1>


    ./package.json



    {
    "name": "electron-hot-reload-boilerplate",
    "version": "1.0.0",
    "description": "An Electron Boilerplate demonstrating hot reloading",
    "main": "main.js",
    "scripts": {
    "start": "electron ."
    },
    "repository": "https://github.com/link/to/your/repo",
    "keywords": ,
    "author": "You",
    "license": "CC-BY-SA-3.0",
    "dependencies": {
    "electron": "^3.0.9",
    "electron-reload": "^1.3.0"
    }
    }


    Install with:



    > npm install


    Run with:



    > npm start





    share|improve this answer


























    • Thanks, I tried on Windows and when I save a change on my angular component, i got a white page...

      – Clément Drouin
      Nov 24 '18 at 15:00


















    1














    electron-reload by default only reloads the WebContents of all open BrowserWindows when a file changes. If you want to restart Electron (i.e. if you want changes to the Electron main process file to reload the application), then what you're looking for is a "hard reset".



    To do this you'll have to set the electron app path, like so:



    require('electron-reload')(__dirname, {
    electron: path.join(__dirname, 'node_modules/.bin/electron.cmd')
    });


    The documentation says that the path should be to ./node_modules/.bin/electron, but I've only been able to get it to work using ./node_modules/.bin/electron.cmd. This is apparently an issue with Windows machines, and supposedly pointing to the executable works on MacOS. This may also be the case on Linux systems.



    The following should be all the files you need for a boilerplate example:



    ./main.js



    const { app, BrowserWindow } = require('electron')
    const path = require('path')
    const url = require('url')

    require('electron-reload')(__dirname, {
    electron: path.join(__dirname, 'node_modules/.bin/electron.cmd')
    });

    let mainWindow = null

    function main() {
    mainWindow = new BrowserWindow()

    mainWindow.loadURL(
    url.format({
    pathname: path.join(__dirname, '/dist/index.html'),
    protocol: 'file:',
    slashes: true
    })
    )

    mainWindow.on('closed', () => {
    mainWindow = null
    })
    }

    app.on('ready', main)

    app.on('window-all-closed', () => {
    if (process.platform !== 'darwin') {
    app.quit()
    }
    })

    app.on('activate', () => {
    if (mainWindow === null) {
    main()
    }
    })


    ./index.html



    <h1>Hello World!</h1>


    ./package.json



    {
    "name": "electron-hot-reload-boilerplate",
    "version": "1.0.0",
    "description": "An Electron Boilerplate demonstrating hot reloading",
    "main": "main.js",
    "scripts": {
    "start": "electron ."
    },
    "repository": "https://github.com/link/to/your/repo",
    "keywords": ,
    "author": "You",
    "license": "CC-BY-SA-3.0",
    "dependencies": {
    "electron": "^3.0.9",
    "electron-reload": "^1.3.0"
    }
    }


    Install with:



    > npm install


    Run with:



    > npm start





    share|improve this answer


























    • Thanks, I tried on Windows and when I save a change on my angular component, i got a white page...

      – Clément Drouin
      Nov 24 '18 at 15:00
















    1












    1








    1







    electron-reload by default only reloads the WebContents of all open BrowserWindows when a file changes. If you want to restart Electron (i.e. if you want changes to the Electron main process file to reload the application), then what you're looking for is a "hard reset".



    To do this you'll have to set the electron app path, like so:



    require('electron-reload')(__dirname, {
    electron: path.join(__dirname, 'node_modules/.bin/electron.cmd')
    });


    The documentation says that the path should be to ./node_modules/.bin/electron, but I've only been able to get it to work using ./node_modules/.bin/electron.cmd. This is apparently an issue with Windows machines, and supposedly pointing to the executable works on MacOS. This may also be the case on Linux systems.



    The following should be all the files you need for a boilerplate example:



    ./main.js



    const { app, BrowserWindow } = require('electron')
    const path = require('path')
    const url = require('url')

    require('electron-reload')(__dirname, {
    electron: path.join(__dirname, 'node_modules/.bin/electron.cmd')
    });

    let mainWindow = null

    function main() {
    mainWindow = new BrowserWindow()

    mainWindow.loadURL(
    url.format({
    pathname: path.join(__dirname, '/dist/index.html'),
    protocol: 'file:',
    slashes: true
    })
    )

    mainWindow.on('closed', () => {
    mainWindow = null
    })
    }

    app.on('ready', main)

    app.on('window-all-closed', () => {
    if (process.platform !== 'darwin') {
    app.quit()
    }
    })

    app.on('activate', () => {
    if (mainWindow === null) {
    main()
    }
    })


    ./index.html



    <h1>Hello World!</h1>


    ./package.json



    {
    "name": "electron-hot-reload-boilerplate",
    "version": "1.0.0",
    "description": "An Electron Boilerplate demonstrating hot reloading",
    "main": "main.js",
    "scripts": {
    "start": "electron ."
    },
    "repository": "https://github.com/link/to/your/repo",
    "keywords": ,
    "author": "You",
    "license": "CC-BY-SA-3.0",
    "dependencies": {
    "electron": "^3.0.9",
    "electron-reload": "^1.3.0"
    }
    }


    Install with:



    > npm install


    Run with:



    > npm start





    share|improve this answer















    electron-reload by default only reloads the WebContents of all open BrowserWindows when a file changes. If you want to restart Electron (i.e. if you want changes to the Electron main process file to reload the application), then what you're looking for is a "hard reset".



    To do this you'll have to set the electron app path, like so:



    require('electron-reload')(__dirname, {
    electron: path.join(__dirname, 'node_modules/.bin/electron.cmd')
    });


    The documentation says that the path should be to ./node_modules/.bin/electron, but I've only been able to get it to work using ./node_modules/.bin/electron.cmd. This is apparently an issue with Windows machines, and supposedly pointing to the executable works on MacOS. This may also be the case on Linux systems.



    The following should be all the files you need for a boilerplate example:



    ./main.js



    const { app, BrowserWindow } = require('electron')
    const path = require('path')
    const url = require('url')

    require('electron-reload')(__dirname, {
    electron: path.join(__dirname, 'node_modules/.bin/electron.cmd')
    });

    let mainWindow = null

    function main() {
    mainWindow = new BrowserWindow()

    mainWindow.loadURL(
    url.format({
    pathname: path.join(__dirname, '/dist/index.html'),
    protocol: 'file:',
    slashes: true
    })
    )

    mainWindow.on('closed', () => {
    mainWindow = null
    })
    }

    app.on('ready', main)

    app.on('window-all-closed', () => {
    if (process.platform !== 'darwin') {
    app.quit()
    }
    })

    app.on('activate', () => {
    if (mainWindow === null) {
    main()
    }
    })


    ./index.html



    <h1>Hello World!</h1>


    ./package.json



    {
    "name": "electron-hot-reload-boilerplate",
    "version": "1.0.0",
    "description": "An Electron Boilerplate demonstrating hot reloading",
    "main": "main.js",
    "scripts": {
    "start": "electron ."
    },
    "repository": "https://github.com/link/to/your/repo",
    "keywords": ,
    "author": "You",
    "license": "CC-BY-SA-3.0",
    "dependencies": {
    "electron": "^3.0.9",
    "electron-reload": "^1.3.0"
    }
    }


    Install with:



    > npm install


    Run with:



    > npm start






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 24 '18 at 3:43

























    answered Nov 24 '18 at 0:32









    Tiny GiantTiny Giant

    13.4k64056




    13.4k64056













    • Thanks, I tried on Windows and when I save a change on my angular component, i got a white page...

      – Clément Drouin
      Nov 24 '18 at 15:00





















    • Thanks, I tried on Windows and when I save a change on my angular component, i got a white page...

      – Clément Drouin
      Nov 24 '18 at 15:00



















    Thanks, I tried on Windows and when I save a change on my angular component, i got a white page...

    – Clément Drouin
    Nov 24 '18 at 15:00







    Thanks, I tried on Windows and when I save a change on my angular component, i got a white page...

    – Clément Drouin
    Nov 24 '18 at 15:00















    0














    Isn't app.relaunch() the way to go to perform a "hard reset"?




    app.relaunch([options])





    • options Object (optional)



      • args String


      • execPath String (optional)




    Relaunches the app when current instance exits.



    By default the new instance will use the same working directory and
    command line arguments with current instance. When args is specified,
    the args will be passed as command line arguments instead. When
    execPath is specified, the execPath will be executed for relaunch
    instead of current app.



    Note that this method does not quit the app when executed, you have to
    call app.quit or app.exit after calling app.relaunch to make the
    app restart.







    share|improve this answer
























    • The question askes how to use electron-reload which is a package that monitors files in a directory for changes and restarts the application when changes are made. app.relaunch is just a method to relaunch the app, it doesn't monitor any files. So no, this does not in any way answer the question.

      – Tiny Giant
      Nov 26 '18 at 16:20
















    0














    Isn't app.relaunch() the way to go to perform a "hard reset"?




    app.relaunch([options])





    • options Object (optional)



      • args String


      • execPath String (optional)




    Relaunches the app when current instance exits.



    By default the new instance will use the same working directory and
    command line arguments with current instance. When args is specified,
    the args will be passed as command line arguments instead. When
    execPath is specified, the execPath will be executed for relaunch
    instead of current app.



    Note that this method does not quit the app when executed, you have to
    call app.quit or app.exit after calling app.relaunch to make the
    app restart.







    share|improve this answer
























    • The question askes how to use electron-reload which is a package that monitors files in a directory for changes and restarts the application when changes are made. app.relaunch is just a method to relaunch the app, it doesn't monitor any files. So no, this does not in any way answer the question.

      – Tiny Giant
      Nov 26 '18 at 16:20














    0












    0








    0







    Isn't app.relaunch() the way to go to perform a "hard reset"?




    app.relaunch([options])





    • options Object (optional)



      • args String


      • execPath String (optional)




    Relaunches the app when current instance exits.



    By default the new instance will use the same working directory and
    command line arguments with current instance. When args is specified,
    the args will be passed as command line arguments instead. When
    execPath is specified, the execPath will be executed for relaunch
    instead of current app.



    Note that this method does not quit the app when executed, you have to
    call app.quit or app.exit after calling app.relaunch to make the
    app restart.







    share|improve this answer













    Isn't app.relaunch() the way to go to perform a "hard reset"?




    app.relaunch([options])





    • options Object (optional)



      • args String


      • execPath String (optional)




    Relaunches the app when current instance exits.



    By default the new instance will use the same working directory and
    command line arguments with current instance. When args is specified,
    the args will be passed as command line arguments instead. When
    execPath is specified, the execPath will be executed for relaunch
    instead of current app.



    Note that this method does not quit the app when executed, you have to
    call app.quit or app.exit after calling app.relaunch to make the
    app restart.








    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 25 '18 at 4:34









    MikaeruMikaeru

    1,10018




    1,10018













    • The question askes how to use electron-reload which is a package that monitors files in a directory for changes and restarts the application when changes are made. app.relaunch is just a method to relaunch the app, it doesn't monitor any files. So no, this does not in any way answer the question.

      – Tiny Giant
      Nov 26 '18 at 16:20



















    • The question askes how to use electron-reload which is a package that monitors files in a directory for changes and restarts the application when changes are made. app.relaunch is just a method to relaunch the app, it doesn't monitor any files. So no, this does not in any way answer the question.

      – Tiny Giant
      Nov 26 '18 at 16:20

















    The question askes how to use electron-reload which is a package that monitors files in a directory for changes and restarts the application when changes are made. app.relaunch is just a method to relaunch the app, it doesn't monitor any files. So no, this does not in any way answer the question.

    – Tiny Giant
    Nov 26 '18 at 16:20





    The question askes how to use electron-reload which is a package that monitors files in a directory for changes and restarts the application when changes are made. app.relaunch is just a method to relaunch the app, it doesn't monitor any files. So no, this does not in any way answer the question.

    – Tiny Giant
    Nov 26 '18 at 16:20











    0














    I found this : https://github.com/maximegris/angular-electron
    It's an empty project template, using Electron and Angular.
    Execute yarn start allow the hot reloading.
    It's well written in the README.md !






    share|improve this answer




























      0














      I found this : https://github.com/maximegris/angular-electron
      It's an empty project template, using Electron and Angular.
      Execute yarn start allow the hot reloading.
      It's well written in the README.md !






      share|improve this answer


























        0












        0








        0







        I found this : https://github.com/maximegris/angular-electron
        It's an empty project template, using Electron and Angular.
        Execute yarn start allow the hot reloading.
        It's well written in the README.md !






        share|improve this answer













        I found this : https://github.com/maximegris/angular-electron
        It's an empty project template, using Electron and Angular.
        Execute yarn start allow the hot reloading.
        It's well written in the README.md !







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 26 '18 at 16:03









        Clément DrouinClément Drouin

        12617




        12617






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53453504%2fhot-reload-using-electron-and-angular%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            TypeError: fit_transform() missing 1 required positional argument: 'X'