aklinker1 / vite-plugin-web-extension

Vite plugin for developing Chrome/Web Extensions
https://vite-plugin-web-extension.aklinker1.io/
MIT License
537 stars 46 forks source link

using firefox instead of chrome during dev builds #187

Closed Yakiyo closed 3 months ago

Yakiyo commented 3 months ago

Hi, during development i use pnpm dev command which opens up a new chrome instance for testing the extension. How would i configure it to open up firefox instead of chrome? i tried searching through the docs but couldn't find any thing on changing the browser. any help would be appreciated

aklinker1 commented 3 months ago

The plugin accepts a browser option:

https://github.com/aklinker1/vite-plugin-web-extension/blob/9343f14f122b8a0a0b89176af0f83c8936177d67/packages/vite-plugin-web-extension/src/options.ts#L52-L57

I could have sworn this was documented somewhere... but I guess not? I couldn't find it in the docs either.

// vite.config.ts
export default defineConfig({
  plugins: [
    WebExtension({
      browser: process.env.TARGET_BROWSER,
    }),
  ],
});

Then run:

# Start chrome
vite

# Start Firefox
TARGET_BROWSER=firefox vite
Yakiyo commented 3 months ago
// vite.config.ts
export default defineConfig({
  plugins: [
    WebExtension({
      browser: process.env.TARGET_BROWSER,
    }),
  ],
});

that really helps. thanks a lot