Skip to content
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

Develop for Firefox and Chrome #34

Open
socketopp opened this issue Jan 22, 2024 · 3 comments
Open

Develop for Firefox and Chrome #34

socketopp opened this issue Jan 22, 2024 · 3 comments

Comments

@socketopp
Copy link

What steps are necessary to make this adapter work both with chrome and firefox?

@Jack-Barry
Copy link
Contributor

I'm new here, just getting started trying to build a cross-browser extension with SvelteKit, so take this all with a big fat grain of salt.

From the looks of it in the README, you'd have several <PLATFORM>_manifest.json files in static, only one of which will be used each time you build.

In svelte.config.js, the adapter function accepts a manifest attribute as part of its options. So you'd likely need to do something like have an environment variable for PLATFORM_TARGET, set it to "chrome" or "firefox", then have the manifest set accordingly, maybe the pages and/or assets attributes as well (if you want to output to different folders for each version).

Doesn't have to work exactly like that, but that seems like how to do it. Aside from that, may want to look into mozilla/webextention-polyfill for cross-browser compatible plugin APIs.

@michmich112
Copy link
Owner

It should work for all chromium based clients but @Jack-Barry's response is accurate. We could make a generic fork for all browsers with polyfills

@Jack-Barry
Copy link
Contributor

I've got a somewhat crude version of this working now leveraging unplugin-auto-import, not sure if it'll pan out all the way though.

I came up with the approach by taking a look at chrome-ext-mv3-starter which is using Vite.

As of now, there's a build warning and VS Code complains that browser is not defined, but when I tested the extension in both Chrome and Firefox it works fine. I haven't had any luck once browser referenced in a script tag, though, so I'll probably end up digging into that whole thing later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants