-
-
Notifications
You must be signed in to change notification settings - Fork 107
HOWTO develop chrome extensions with auto reload
hbt edited this page Apr 1, 2012
·
1 revision
When it comes to developing chrome extensions, you can waste endless amount of hours reloading the extension after every change.
Your workflow looks something like this
- make a change in a file
- go to chrome://extensions/
- click "reload"
- reload your tab
- change appears then back to 1
Instead we came up with a small hack to automatically reload the extension after a file has been changed.
How it works:
- a script watches the vrome directory for file changes
- whenever a file is modified, the script updates a temporary file to indicate we have a change
- in chrome://extensions/ we open the developer tools console (CTRL + Shift + J), we then insert a function. The function makes an ajax call every X milliseconds to the server
- The server will return the value from the temporary file
- When that value changes, the extension is reload via Javascript
Clear step by step instructions on how to make it work:
- install
watch_and_do
gem install watch_and_do -v 0.0.3
- go to root of project
~/vrome
and start watching for changes usingwatch_and_do . js utils/update_version.rb
Whenever ajs
file is modified, it will call theutils/update_version.rb
script - start the ruby server located in
system/ruby/bin/vrome
- go to
chrome://extensions/
- unpack the extension if it isn't already + make sure it is enabled
- open the developer tools console (CTRL + SHIFT + J)
- copy/paste the content of
reload_extension.js
inutils
- do not forget to modify the extensionID variable (view
reload_extension.js
script) - You can now test it by making a change in one of the JS file. watch_and_do will report the change and update the version number then the code in the console in
chrome://extensions/
will call the server and reload the extension - Develop chrome extensions efficiently
Please note you can use something other than watch_and_do
e.g inotifywatch
to watch for file changes
Please also note that you still have to reload the tab -- maybe that's something we could automate too.