web-ext
web-ext copied to clipboard
Safari support for `web-ext run`
I thought I saw an issue discussing the possibility of a Safari target but apparently "safari" is almost never mentioned in this repo.
I'm looking for a solution to develop extensions in Safari and the biggest hurdle at the moment is auto reload, which web-ext
generally offers in other browsers with the run
command.
Is there any chance of Safari ever being supported by web-ext
in any capacity? Or is anyone aware of any auto-reload method for Safari? Currently it requires a full Xcode build for every change, which might take 15s-30s.
Related unanswered StackOverflow question: https://stackoverflow.com/q/21957024/288906
Hello from the Safari team! This is an area we are interested in improving since we added the Web Extension conversion tool.
On the topic of auto-reload, Safari supports this already. (The StackOverflow question was from 2014 before we supported cross-browser Web Extensions.) If the same extension is re-built in Xcode, Safari will detect the change and reload the background page and inject the content scripts again. A reload of tabs or navigation to another page might be needed to ensure the content scripts are right.
On the topic of build times, if you don't generate the Xcode project each time, I'd expect the build time to be quicker. If you are not adding new files, the Xcode project can be reused. (That helps the auto-reload case above too, since it is the same build result app.) That said, if you are seeing build times of the same project taking that long, please file feedback via Feedback Assistant.
In theory web-ext
could use the xcrun safari-web-extension-converter
tool with --no-prompt --no-open
and the command-line xcodebuild
to get you most of the way there. You would still need to open the built app once, and enable the extension manually the first time, since Safari does not support any automated way to enable extensions.
Thank you for the response!
This is what I generally use the build the project, I never thought about running the converter multiple times:
xcodebuild -project 'safari/Refined GitHub.xcodeproj'"
https://github.com/sindresorhus/refined-github/blob/b9dea1a78f79d4d8da129d3f2151892a655f0df9/package.json#L13
Admittedly to doesn't always take that long, but on a very minimal extension (38KB + icons) I'm seeing 5+ seconds plus the time it takes to manually run the command. Ideally the built extension would keep a live reference to the original files and reload them without any build, but I sense that that might not be possible.