From 425bd3bac07899e38e5b388b02bc4778e0e60efb Mon Sep 17 00:00:00 2001 From: ThinkRealize Date: Fri, 4 Aug 2023 12:12:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9C=AA=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=20vendor=20=E5=AF=BC=E8=87=B4=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit webpack build 的时候会生成 vendor.js 文件,如果不把 vendor.js 文件添加到 content-script 中会导致,模块未加载,运行失败。 --- src/manifest.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/manifest.ts b/src/manifest.ts index fb7f360..f53c432 100644 --- a/src/manifest.ts +++ b/src/manifest.ts @@ -23,6 +23,10 @@ const manifest: Manifest.WebExtensionManifest = { service_worker: 'js/background.js', }, content_scripts: [ + { + matches: [''], + js: [...(__DEV__ ? [] : ['js/vendor.js'])], + }, { matches: ['https://github.com/*'], css: ['css/all.css'], From 6e6438054bf5e8001742844a5f71d571c015c2cf Mon Sep 17 00:00:00 2001 From: ThinkRealize Date: Fri, 4 Aug 2023 13:13:27 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8Djs=E5=80=BC=E6=98=AF?= =?UTF-8?q?=E7=A9=BA=E6=97=B6=E5=8A=A0=E8=BD=BD=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/manifest.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/manifest.ts b/src/manifest.ts index f53c432..306d1c5 100644 --- a/src/manifest.ts +++ b/src/manifest.ts @@ -23,10 +23,6 @@ const manifest: Manifest.WebExtensionManifest = { service_worker: 'js/background.js', }, content_scripts: [ - { - matches: [''], - js: [...(__DEV__ ? [] : ['js/vendor.js'])], - }, { matches: ['https://github.com/*'], css: ['css/all.css'], @@ -53,5 +49,11 @@ const manifest: Manifest.WebExtensionManifest = { '128': 'icons/extension-icon-x128.png', }, }; +if (!__DEV__) { + manifest.content_scripts?.unshift({ + matches: [''], + js: ['js/vendor.js'], + }); +} export default manifest;