Skip to content

Commit

Permalink
Fix reload strategy for Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
cezaraugusto committed Sep 21, 2024
1 parent d1839c4 commit 2112210
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class TargetWebExtensionPlugin {
: 'minimum-chromium-file.mjs'
)

const dirname = path.dirname(this.manifestPath!)
let manifestBg: Record<string, any> | undefined =
utils.filterKeysForThisBrowser(manifest, browser)

Expand All @@ -38,19 +39,20 @@ export class TargetWebExtensionPlugin {
const backgroundScripts = manifestBg?.scripts

if (backgroundScripts && backgroundScripts.length > 0) {
this.ensureFileExists(backgroundScripts[0])
const backgroundScriptsPath = path.join(dirname, backgroundScripts[0])
this.ensureFileExists(backgroundScriptsPath)
} else {
this.addDefaultEntry(compiler, 'background/script', minimumBgScript)
}
} else {
const dirname = path.dirname(this.manifestPath!)
manifestBg = manifest.background

if (manifest.manifest_version === 3) {
const serviceWorker = manifestBg?.service_worker

if (serviceWorker) {
const serviceWorkerPath = path.join(dirname, serviceWorker)

this.ensureFileExists(serviceWorkerPath)
} else {
this.addDefaultEntry(
Expand Down Expand Up @@ -97,6 +99,10 @@ export class TargetWebExtensionPlugin {

private getEntryName(manifest: Manifest) {
if (manifest.background) {
if (this.browser === 'firefox' || this.browser === 'gecko-based') {
return {pageEntry: 'background/script'}
}

if (manifest.manifest_version === 3) {
return {serviceWorkerEntry: 'background/service_worker'}
}
Expand Down

0 comments on commit 2112210

Please sign in to comment.