Chrome Extension Hot Reload
This is an npm package that can be imported in background.js
and popup.js
files to make hot reloading possible in extensions.
Using this package, extensions' popups can be hot reloaded without having to close them!
xpl since this package is initially based on his/her package crx-hotreload for timestamp retrieval and main ideas.
Special Thanks toInstall
Install it via npm install --save chrome-extension-hot-reload
Usage
In your background.js
script add the following in top
;HotReloadstart;
In your popup.js
script add the following in top
;HotReload;
connect
in options page or content scripts, they should already work automatically if you have called start
in background script.
You should NOT call Alternatively, (if you don't want to import both the start & connect scripts in both background and popup files you can import them separately as in below)
;;
;;
Alternatively, if you prefer ES5, you can import the module as in below (all of them should work)
const HotReload = ;const start = ;const connect = ;
Configuration
In the connect
method you can pass an options
object to pass custom configurations.
;HotReload;
Features
- Doesn't close
popup
/options
page (doesn't force reloads the extension) - Using only in
background.js
is enough for hot reloading options page - Can also hot reload popups, using
start/connect
syntax (even if you do not have abackground script
, in order to get hot reloading in popups, you should create abackground script
file in which you callstart
) - Reloads tabs just as crx-hotreload.
- Doesn't run if the extension is not in development mode just as crx-hotreload.