samuelsimoes / chrome-extension-webpack-boilerplate

A basic foundation boilerplate for rich Chrome Extensions using Webpack to help you write modular and modern Javascript code, load CSS easily and automatic reload the browser on code changes.
MIT License
1.7k stars 347 forks source link

Enabling HMR for content scripts #78

Open arseneyr opened 4 years ago

arseneyr commented 4 years ago

I have a change to enable Hot Module Reloading for Chrome extension content scripts:

https://github.com/arseneyr/chrome-extension-webpack-boilerplate/tree/content-hmr

This change includes a new webpack plugin that does the following:

There are also some changes to the webpack-dev-server parameters so that the websocket client connects inside content scripts:

I'm happy to open a PR if you think this change is valuable.

ShravanSunder commented 4 years ago

how would you integrate this into the react branch? i'd like to use this in my project. @arseneyr

arseneyr commented 4 years ago

I have a branch where I merged the react changes with the content HMR changes: https://github.com/arseneyr/chrome-extension-webpack-boilerplate/tree/react

Haven't tested it thoroughly but you can give it a try.

Godiswill commented 2 years ago

I created a repo by create-react-app, it uses react-refresh to achieve partial refresh and uses sse to enable HMR for Chrome extension content scripts: cra-crx-boilerplate