Closed ladas-larry closed 9 years ago
I'm using this chromereload.js to make it working with livereload:
'use strict';
// The reload client has a compatibility with livereload, only supports reload command.
var LIVERELOAD_HOST = 'localhost:';
var LIVERELOAD_PORT = 35729;
var connection = new WebSocket('ws://' + LIVERELOAD_HOST + LIVERELOAD_PORT + '/livereload');
connection.onerror = function (error) {
console.log('reload connection got error:', error);
};
connection.onmessage = function (e) {
if (e.data) {
var data = JSON.parse(e.data);
if (data && data.command === 'reload') {
chrome.runtime.reload();
}
}
};
Then in manifest.json:
"background": {
"scripts": [
"chromereload.js",
"background.js"
]
},
I am busy till next week, but i will look at it. I can try to "hack" webpack to refresh whole extension if hot reload is not available.
Include full reload directly into webpack when hot not available. Not best solution, but works fine for now. https://github.com/schovi/webpack-chrome-extension/commit/f5de65af61814d0e96fa0a7c17f35d61293645a0
Is there a reason why chrome.runtime.reload would be undefined?
After changing the background script extension says "The following couldn't be hot updated: (They would need a full reload!)". Wouldn't it be more convenient to run chrome.runtime.reload(); in such cases? Or at least have an option that would allow full reload.