diff --git a/package.json b/package.json index f9163c2..9293284 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,14 @@ { "name": "reels-master", - "version": "1.1.2", + "version": "1.2.1", "description": "Chrome extension for Instagram Reels with volume control and download functionality", "main": "index.js", "scripts": { - "dev": "BROWSER=chrome vite build --watch", - "dev:firefox": "BROWSER=firefox vite build --watch", + "dev": "BROWSER=chrome BUILD_ENTRY=background vite build && BROWSER=chrome BUILD_ENTRY=content vite build --watch", + "dev:firefox": "BROWSER=firefox BUILD_ENTRY=background vite build && BROWSER=firefox BUILD_ENTRY=content vite build --watch", "build": "pnpm build:chrome && pnpm build:firefox", - "build:chrome": "BROWSER=chrome vite build", - "build:firefox": "BROWSER=firefox vite build", + "build:chrome": "BROWSER=chrome BUILD_ENTRY=background vite build && BROWSER=chrome BUILD_ENTRY=content vite build", + "build:firefox": "BROWSER=firefox BUILD_ENTRY=background vite build && BROWSER=firefox BUILD_ENTRY=content vite build", "bundle": "vite build && node scripts/bundle.js", "type-check": "tsc --noEmit" }, diff --git a/src/manifest.firefox.json b/src/manifest.firefox.json index 9f107e8..4c82244 100644 --- a/src/manifest.firefox.json +++ b/src/manifest.firefox.json @@ -4,7 +4,7 @@ "version": "1.1.2", "description": "Enhance your Instagram experience with Reels Master - download reels, seek through videos, and more!", "background": { - "service_worker": "background/background.js" + "scripts": ["background/background.js"] }, "homepage_url": "https://shiftyspace.ru", "author": "ShiftyX1", diff --git a/vite.config.ts b/vite.config.ts index 19a3396..e389339 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -5,15 +5,27 @@ import AdmZip from 'adm-zip'; const browser = process.env.BROWSER || 'chrome'; +const buildEntry = process.env.BUILD_ENTRY; // 'background' | 'content' | undefined (both) + +const inputs = + buildEntry === 'background' + ? { background: resolve(__dirname, 'src/background/service-worker.ts') } + : buildEntry === 'content' + ? { content: resolve(__dirname, 'src/content/content.ts') } + : { + background: resolve(__dirname, 'src/background/service-worker.ts'), + content: resolve(__dirname, 'src/content/content.ts'), + }; + +const shouldEmptyOutDir = buildEntry !== 'content'; +const isFinalPass = buildEntry !== 'background'; + export default defineConfig({ build: { outDir: 'dist', - emptyOutDir: true, + emptyOutDir: shouldEmptyOutDir, rollupOptions: { - input: { - background: resolve(__dirname, 'src/background/service-worker.ts'), - content: resolve(__dirname, 'src/content/content.ts'), - }, + input: inputs, output: { entryFileNames: '[name]/[name].js', chunkFileNames: '[name].js', @@ -25,6 +37,7 @@ export default defineConfig({ { name: 'copy-manifest', closeBundle() { + if (!isFinalPass) return; try { copyFileSync( resolve(__dirname, `src/manifest.${browser}.json`), @@ -39,6 +52,7 @@ export default defineConfig({ { name: 'create-zip', closeBundle() { + if (!isFinalPass) return; if (process.env.NODE_ENV === 'production' || !process.argv.includes('--watch')) { try { const zip = new AdmZip();