rubenspgcavalcante/webpack-chrome-extension-reloader

Hot reload for pages

jonathan-s opened this issue · 3 comments

Type:

  • bug
  • feature
  • enhancement
  • question

Environment:

  • OS:
  • Library Version:

I'm going to open a PR:

  • yes
  • no

Description:
It would be nice if this plugin also could support hot reloading for pages defined in web_accessible_resources somehow. Right now when a change is made the page is just closed. Perhaps these pages could be served directly by the dev server?

Hi @jonathan-s , thanks for the feedback.
Checking here the dev-server will not be able to handle the job as the Chrome still the one that manages this resources (available on chrome-extension://[PACKAGE ID]/[PATH])
If you mark all this resources using the Copy Webpack Plugin or even making the webpack process and output it, as another entry point, the hot-reload still will do the job, reloading the extension and then all the pages affected by it.

To not reload the page, I think that's what you want to say, like some kind of hot module reload (and not extension reload), isn't possible as this plugin assumes the behaviour to always reload the page so the content-script that will be executed are the fresh ones.

To do a proper module-reload is more hard. You need to inject the new resource on the fly without reloading the page, probably using eval and other tricks, and involves a lot of concepts that I think is more complex or even inviable on an extension context.

Anyway, I will see what I can do on this case, and if is doable or not.

@rubenspgcavalcante Thank you for your reply. Perhaps you are right that this is out of scope of the extension reloader. What I ended up doing was using the normal webpack dev server to serve each part of the extension. That way you're still able to get the fast iteration and you can do any final checks once you're 95% there.

That Perhaps that could be included in the documentation as a suggestion for developing the option and popup pages.

That's a good idea :)
Thanks for the feedback!