diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ad0c893..b597bbb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,8 +23,10 @@ jobs: run: bun install --frozen-lockfile - name: Run Typecheck run: bun run typecheck - - name: Build Extension + - name: Build Extension (Chrome MV3) run: bun run build + - name: Build Extension (Firefox MV2) + run: bun run build:firefox # release job, runs on main only after successful build release: diff --git a/README.md b/README.md index c7f0473..5e5d218 100644 --- a/README.md +++ b/README.md @@ -44,20 +44,34 @@ npm run build npm run zip ``` -Firefox builds are also supported: +To manually load the production build as an unpacked extension in Chrome: + +1. Run `npm run build`. +2. Open `chrome://extensions/`. +3. Enable Developer Mode (top right). +4. Click "Load Unpacked" and select the `.output/chrome-mv3/` folder. + +### Firefox development + +Firefox builds (MV2) are also supported. WXT normalizes the MV3 manifest into +the MV2 shape automatically; the `chrome.scripting.*` API used by the background +worker is supported in Firefox 102 and later. ```bash +# dev server with HMR, launches Firefox with the extension auto-loaded npm run dev:firefox + +# production build (writes to .output/firefox-mv2/) npm run build:firefox + +# zip for AMO submission (writes to .output/--firefox.zip) npm run zip:firefox ``` -To manually load the production build as an unpacked extension in Chrome: - -1. Run `npm run build`. -2. Open `chrome://extensions/`. -3. Enable Developer Mode (top right). -4. Click "Load Unpacked" and select the `.output/chrome-mv3/` folder. +To customise the browser binary that `npm run dev` / `npm run dev:firefox` +launches (e.g. point at Firefox Developer Edition), copy +`web-ext.config.example.ts` to `web-ext.config.ts` and edit the paths. The +`web-ext.config.ts` file is gitignored — keep it local to your machine. ## License diff --git a/web-ext.config.example.ts b/web-ext.config.example.ts new file mode 100644 index 0000000..d521568 --- /dev/null +++ b/web-ext.config.example.ts @@ -0,0 +1,13 @@ +import { defineWebExtConfig } from "wxt" + +// Copy this file to `web-ext.config.ts` (gitignored) and adjust paths for your +// machine. WXT uses it to launch the browser during `wxt` / `wxt -b firefox`. +// +// See https://wxt.dev/guide/essentials/config/browser-startup.html +export default defineWebExtConfig({ + binaries: { + chrome: "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe", + firefox: "firefoxdeveloperedition", + }, + startUrls: ["https://schoolbox.education/"], +}) diff --git a/wxt.config.ts b/wxt.config.ts index 31a6a47..9c737e9 100644 --- a/wxt.config.ts +++ b/wxt.config.ts @@ -3,6 +3,9 @@ import { defineConfig } from "wxt" // See https://wxt.dev/api/config.html export default defineConfig({ srcDir: "src", + // Firefox MV2 build: WXT normalizes host_permissions, web_accessible_resources, + // and action -> browser_action automatically. The `scripting` permission and + // `chrome.scripting.*` API are supported in Firefox MV2 (Firefox 102+). manifest: { name: "UltraBox", description: "A Chrome extension for SchoolBox.", @@ -29,4 +32,10 @@ export default defineConfig({ }, ], }, + // UltraBox is an existing extension (currently distributed for Chrome). The + // Firefox data-collection consent requirement only applies to brand-new + // listings on AMO; suppress the build-time warning until we list there. + suppressWarnings: { + firefoxDataCollection: true, + }, })