feat: add dev-firefox build-firefox npm scripts

This commit is contained in:
Hakadao
2023-04-12 18:04:14 +08:00
parent 1663b45597
commit b1ccf3e6fc
3 changed files with 7 additions and 4 deletions

View File

@@ -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",

View File

@@ -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)

View File

@@ -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',