firefox.mjs (875 bytes)
1 // Stages the package for addons.mozilla.org in build/firefox. Firefox 2 // ignores background.service_worker, and the linter of addons.mozilla.org 3 // warns about it, so the staged manifest.json leaves it out. Chrome needs 4 // it, so manifest.json keeps it. "npm run build:firefox" builds the zip from 5 // the staged copy. 6 import { cpSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"; 7 8 const out = "build/firefox"; 9 const skip = new Set(["build", "node_modules", "web-ext-artifacts", ".git"]); 10 11 rmSync(out, { recursive: true, force: true }); 12 for (const name of readdirSync(".")) { 13 if (!skip.has(name)) cpSync(name, `${out}/${name}`, { recursive: true }); 14 } 15 const manifest = JSON.parse(readFileSync(`${out}/manifest.json`, "utf8")); 16 delete manifest.background.service_worker; 17 writeFileSync(`${out}/manifest.json`, JSON.stringify(manifest, null, 2) + "\n");