Closed ohager closed 4 months ago
Content scripts are always built using lib mode, so they never have access to import.meta.hot
.
The auto open browser function always starts a "clean" browser instance. When using another browser instance the extension does not update automatically. How can I make auto-update work with my "own" browser instance
This is something I found out recently that's not documented, but you can use chrome's --user-data-dir
and it will create a profile that remembers the website you're logged into for one project. You'll have to spend a couple minutes setting up that profile once you run it for the first time, but after that it will remember everything like a normal browser profile.
# ./.webextrc.yml
args:
- --user-data-dir=./chrome-data
Cool, the auto-extension update works nicely when using the auto-launched instance - and using the custom chrome data location improves the DX even more. As for completion here is a list with chrome runner options: https://gist.github.com/dodying/34ea4760a699b47825a766051f47d43b
For those who wants to run in maximized mode, the following config works pretty nice (json5 format used here):
{
// look here for more options:
// https://vite-plugin-web-extension.aklinker1.io/guide/configure-browser-startup.html#available-options
// furthermore:
// chrome: https://gist.github.com/dodying/34ea4760a699b47825a766051f47d43b
"args": [
"--user-data-dir=./.chrome-data",
"--start-maximized=true"
]
}
@aklinker1 do you see a way to auto-reload the content script?
@aklinker1 do you see a way to auto-reload the content script?
https://vite-plugin-web-extension.aklinker1.io/guide/development.html#development-mode -- tried this, but the page is not being reloaded
will close for, as all answered
NOT A BUG - BUT A QUESTION
Summary
I'm trying to make HMR work for a content script. I do know that HMR is somewhat limited for content script, but an auto-reload would be satisifiable already. Unfortunately, I'm not able to make it work.
My current vite.config.js looks like this:
and I use the following snippet in my content script:
But
import.meta.hot
is always undefined.Environment
And a follow up question: The auto open browser function always starts a "clean" browser instance. When using another browser instance the extension does not update automatically. How can I make auto-update work with my "own" browser instance.