Content scripts in dev mode don't work in Firefox
caudurodev opened this issue · comments
Great work on this project! But since I mainly develop in FF I thought I would mention that there is an issue specific to FF which works fine in chromium browsers. If dev mode is enabled (HMR) the content scripts don't even load in the page. Build works fine in FF. Without delete manifest.content_scripts
the development mode works, but requires the extension to be reloaded manually.
- FF
browser.tabs.executeScript()
requiresfile
path starts with '/'. - FF will cache files in memory until the extension is reloaded, instead of reading them from hard drive every time.
OK - so might be worth noting this in the readme or comment in files somewhere? I've switched over to a chromium browser for now to be able to take advantage of all the features in this repo.
@caudurodev for now, you can install web-ext and run web-ext run --source-dir ./extension --browser-console --target=firefox-desktop
from project root. web-ext
will reload firefox extension automatically.
I'm unable to get content scripts working in dev mode in Chrome, too.
Able to reproduce by:
- Cloning
- Installing dependencies
- Running the
dev
script - Running
start:chromium
- Seeing that the content script is not being included
- Running the
build
script - Running
start:chromium
- Seeing that the content script IS being included
@mattrothenberg In my test, web-ext
has a delay in loading extension, if open a url at browser startup quickly(often occurs when web-ext run
with --start-url
command), the extension's background script is not yet executed, so contentscript is not injected. You can open the url in dev mode, wait a moment to refresh the page and see if the extension loads properly.
If it is not the case above, you can open the chrome://extensions/
page, enable developer mode
, and click the view dist/background/index.html
console
tab to see if there is an error message.