Open jonluca opened 2 years ago
Note that it works properly when it's injected via manifest.json
"content_scripts": [
{
"js": ["src/scripts/content-script.ts"],
"matches": ["*://*/*"]
}
],
This should be fixed in@crxjs/vite-plugin@2.0.0-beta.1
.
I'm currently facing the same issue and it is very annoying, is it being fixed?
It's fixed for me, is the version installed @crxjs/vite-plugin@2.0.0-beta.4
?
Ok I'll check it out, Thanks
Hi, that's works fine when the world for JS is "ISOLATED" (default). If is set to "MAIN" the loader not works, because the chorme object isn't exists. I think in case of a script injection, the loader is not necessary.
Exemple that fails
import myScript from "./scripts/content-script?script";
browser.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
if (tab.url && /somedomain.com/.test(tab.url)) {
await browser.scripting.executeScript({
target: { tabId: tab.id },
world: "MAIN",
files: [myScript],
});
}
});
Build tool
Vite
Where do you see the problem?
Describe the bug
I have a script, written in typescript, that is being imported in
background.ts
withimport myScript from "./scripts/content-script?script";
and then run on the page withAny time I edit the content of the file, the file in
dist/scripts
stays the same, and the file in theSources > Content Scripts
tab stays the same. It's only after a full vite kill + restart and a refresh of the extension that it starts working.Reproduction
See above, repo unfortunately is not public.
Logs
No response
System Info
Severity
annoyance