Skip to content

Commit

Permalink
fix: mv2 host_permission merging
Browse files Browse the repository at this point in the history
  • Loading branch information
louisgv committed Jun 29, 2023
1 parent 35acf07 commit 7e51e63
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions cli/plasmo/src/features/manifest-factory/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,16 +488,6 @@ export abstract class PlasmoManifest<T extends ExtensionManifest = any> {
...overide
} = this.overideManifest as T

if (this.bundleConfig.manifestVersion === "mv2") {
base.background = {
...base.background,
...overrideBackground
}
if (Object.keys(base.background).length === 0) {
delete base.background
}
}

if (base.options_ui?.page) {
base.options_ui = {
...base.options_ui,
Expand All @@ -513,6 +503,23 @@ export abstract class PlasmoManifest<T extends ExtensionManifest = any> {
delete base.permissions
}

if (this.bundleConfig.manifestVersion === "mv2") {
base.background = {
...base.background,
...overrideBackground
}
if (Object.keys(base.background).length === 0) {
delete base.background
}
// Host permission is coupled with permission in mv2
if (overide["host_permissions"]?.length > 0) {
base.permissions = [
...(base.permissions || []),
...overide["host_permissions"]
]
}
}

// Populate content_scripts
base.content_scripts = [
...Array.from(this.contentScriptMap.values()).filter(
Expand Down

0 comments on commit 7e51e63

Please sign in to comment.