crxjs / chrome-extension-tools

Bundling Chrome Extensions can be pretty complex. It doesn't have to be.
https://crxjs.dev/vite-plugin
2.55k stars 177 forks source link

Add support for Edge and Firefox #889

Open vioao opened 1 month ago

vioao commented 1 month ago

Describe the problem

Describe the proposed solution

Alternatives considered

Still use a single mainfest.json. But inside the configuration. We could set item for different browser. eg.

Importance

would make my life easier

JoeyDoey commented 1 month ago

shameless plug @vioao . checkout Bedframe. it uses crx under the hood and makes it multi-browser.

you end up with:

- dist/
   - firefox
   - chrome
  - edge

all the vite + crx advantages + multibrowser.

however, as is crx already supports firefox + all chromium (including edge) browsers)

one thing you could do just now to go cross-browser in the standard vite+crx setup is to take advantage of the command and mode features in vite.

  1. update your vite.config to use the function signature instead of the default. i.e
    export default defineConfig(({ command, mode }) => {                                  
    })

nb:

you could expand on this and have an inline vite plugin (just a function) that'll build/dev the specific extension based on the command+mode you pass in.

I hope that makes sense / is helpful

JoeyDoey commented 1 month ago

reference implementation: https://github.com/nyaggah/bedframe/blob/main/packages/core/src/lib/get-manifest.ts#L25