-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get content and background scripts to hot reload as well? #40
Comments
Also curious about this. It seems like v3 with the use of service workers, makes this difficult. |
I was at this most of yesterday and I could not figure out how to hot reload with manifest v3. There has to be a way, because removing the extension and loading it again is just not feasible for development. |
Change your 'notHotReload' to include 'contentScript' and 'background' chromeExtensionBoilerplate: { it appears the 'notHotReload' entry is not intuitively named (at least from the behavior i see - not having to unload and reload my extension). |
Huh @andy-rsa, just tried that but it's not working for me. |
weird, this is what I'm doing in addition.
I had a problem where things stopped working for a bit so i did this
Note: I ran myself in circles for 5 minutes very frustrated that it didn't appear that it was working until I realized I was hitting refresh on the wrong extension in the browser's extension page. Make sure you're clicking refresh on the extension you're developing and hit reload on the page that you're using to test the extension. just to continue the rubber-ducking, remove and reload the extension once just to make sure you're getting the right folder (verify you see the files you're expecting). for reference this is what that part of my webpack.config.js looks like
this is what gets created in my build folder. When you add the extension to your browser, verify you see the files you're expecting. |
hey @andy-rsa, ahhh! thanks for the detail here. So you're right, it is hot reloading into the build folder now BUT for some reason the changes don't make it to chrome unless I hit refresh on the chrome extension. When I make changes in popup, the changes propogate into the extension with only a page refresh and not an extension refresh. Anyways, thanks for the help here! Not having to run npm run build every time is the biggest thing anyways. |
Can confirm that the change made to content script is only reflected on refreshing the page WITH the extension, not just the extension. Interestingly, refreshing the page by itself did not change anything, nor did refreshing the extension by itself. I would also love to find a fix or workaround for this issue. |
Hi, I wrote a package mv3-hot-reload for solving this problem, it is easy to use. |
I cannot seem to get this working with this boilerplate. I am getting a |
@adventurini You should ensure webpack process your dependency code correctly. |
@willliuwillliu how do you inject a react component into an user active tab, i currently inject plain HTML using |
Hi guys, I have just added background & content-scripts auto-reload feature to this boilerplate (with some other not-related modification out of personal taste). checkout this: https://github.com/tyn1998/chrome-extension-boilerplate-react/tree/background-contentScripts-auto-reload IMPORTANT: you should keep service worker devtools page open to keep EventSource connection to devServer! Since service worker will be killed automactically in mv3. I will explain how it works later. please tell me if it works. |
Any update on this issue? |
Sorry if this is asking too much but is there any chance you could cherrypick the change to support hot reload and create a PR? |
Here you go: #110 |
thanks |
Looks like it hasn't been merged yet :( |
I'm having trouble figuring out what to change in webpack config in order to get my content and background scripts to hot reload with the rest of my app.
This is important for me because my extension is injecting a react component into a user's active tab via the content script. For this reason I need the content script to hot reload.
Here is my webpack config, or at least what I think are the relevant parts.
As you can see I removed contentScript from
chromeExtensionBoilerPlate.notHotReload
.Honestly I'm having trouble even understanding how this hot reloading is working, any help here is appreciated!
The text was updated successfully, but these errors were encountered: