diff --git a/package.json b/package.json index 34c7adf4..6b173fda 100644 --- a/package.json +++ b/package.json @@ -8,11 +8,13 @@ "homepage": "https://github.com/hakadao/BewlyBewly", "scripts": { "dev": "npm run clear && cross-env NODE_ENV=development run-p dev:*", + "dev-firefox": "npm run clear && cross-env NODE_ENV=development FIREFOX=true run-p dev:*", "dev:prepare": "esno scripts/prepare.ts", "dev:web": "vite", "dev:js": "npm run build:js -- --mode development", "dev:bg": "tsup --watch ./src", "build": "cross-env NODE_ENV=production run-s clear build:web build:prepare build:js build:bg", + "build-firefox": "cross-env NODE_ENV=production FIREFOX=true run-s clear build:web build:prepare build:js build:bg", "build:prepare": "esno scripts/prepare.ts", "build:web": "vite build", "build:js": "vite build --config vite.config.content.ts", diff --git a/scripts/utils.ts b/scripts/utils.ts index ca400108..03d25ec5 100644 --- a/scripts/utils.ts +++ b/scripts/utils.ts @@ -5,6 +5,7 @@ export const port = parseInt(process.env.PORT || '') || 3303 export const r = (...args: string[]) => resolve(__dirname, '..', ...args) export const isDev = process.env.NODE_ENV !== 'production' export const isWin = process.platform === 'win32' +export const isFirefox = process.env.FIREFOX === 'true' export function log(name: string, message: string) { console.log(black(bgCyan(` ${name} `)), message) diff --git a/src/manifest.ts b/src/manifest.ts index 4dc8a347..598f844e 100644 --- a/src/manifest.ts +++ b/src/manifest.ts @@ -1,7 +1,7 @@ import fs from 'fs-extra' import type { Manifest } from 'webextension-polyfill' import type PkgType from '../package.json' -import { isDev, port, r } from '../scripts/utils' +import { isDev, isFirefox, port, r } from '../scripts/utils' export async function getManifest() { const pkg = await fs.readJSON(r('package.json')) as typeof PkgType @@ -22,9 +22,9 @@ export async function getManifest() { // page: './dist/options/index.html', // open_in_tab: true, // }, - background: { - service_worker: './dist/background/index.mjs', - }, + background: isFirefox + ? { scripts: ['./dist/background/index.mjs'] } + : { service_worker: './dist/background/index.mjs' }, icons: { 16: './assets/icon-512.png', 48: './assets/icon-512.png',