// install
npm i -D electron-reloader
// add this to main.js at top
try { require('electron-reloader')(module);} catch {};
// add this to package.json under `scripts` object
'start': 'electron .'
// now run electron and change file
npm run start
const {getCurrentWindow, globalShortcut} = require('electron').remote;
var reload = ()=>{
getCurrentWindow().reload()
}
globalShortcut.register('F5', reload);
globalShortcut.register('CommandOrControl+R', reload);
// here is the fix bug #3778, if you know alternative ways, please write them
window.addEventListener('beforeunload', ()=>{
globalShortcut.unregister('F5', reload);
globalShortcut.unregister('CommandOrControl+R', reload);
})
/*
To use this code, you need to install the npm package 'electron-reload'
executing this command:
npm install electron-reload
*/
const path = require('path')
require('electron-reload')(__dirname, {
electron: path.join(__dirname, 'node_modules', '.bin', 'electron'),
hardResetMethod: 'exit'
});
Code Example |
---|
Html :: 0 |
Html :: how to add css to html |
Html :: display image in twig |
Html :: add svg to html |
Html :: how to make a div in html |
Html :: add html img tag |
Html :: selected options with link |
Html :: bootstrap icons chevron |
Html :: html.textboxfor add default value |
Html :: open link in new tab |
Html :: bootstrap 4 setup |
Html :: form validation using html/css/js |
Html :: embed link in markdown |
Html :: how to change size of image in html |
Html :: bootstrap modal remove gray background |
Html :: javascript moving text from left to right |
Html :: html clear input after submit |
Html :: call javascript function from a tag |
Html :: dark mode favicon |
Html :: Prettier not formatting HTML files in VS Code |
Html :: how to use lottie in html |
Html :: embed tag in html |
Html :: html typing shortcuts |
Html :: align div in html |
Html :: svg as button |
Html :: time input html |
Html :: html player |
Html :: link in md |
Html :: li html |
Html :: html code for writing text |