Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support of default_panel and default_icon for sidebar_action #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Assets resolved by this plugin:
- `browser_action.default_icon`
- `page_action.default_popup`
- `page_action.default_icon`
- `sidebar_action.default_panel`
- `sidebar_action.default_icon`
- `icons`
- `web_accessible_resources`
- `chrome_url_overrides.bookmarks`
Expand Down
21 changes: 21 additions & 0 deletions src/ManifestAsset.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ManifestAsset extends Asset {
web_accessible_resources: this.processWebAccessibleResources,
browser_action: this.processBrowserAction,
page_action: this.processPageAction,
sidebar_action: this.processSidebarAction,
icons: this.processIcons,
options_ui: this.processOptionsUi,
options_page: this.processOptionsPage,
Expand Down Expand Up @@ -235,6 +236,26 @@ class ManifestAsset extends Asset {
}
}

processSidebarAction() {
const action = this.ast.sidebar_action
if (!action) {
return
}

if (action.default_panel) {
action.default_panel = this.processSingleDependency(
action.default_panel
)
}
const defaultIcon = action.default_icon
if (defaultIcon) {
action.default_icon =
typeof defaultIcon === 'string'
? this.processSingleDependency(defaultIcon)
: this.processAllIcons(defaultIcon)
}
}

processOptionsPage() {
// Chrome
const optionsPage = this.ast.options_page
Expand Down
4 changes: 4 additions & 0 deletions test/integration/web-extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
"options_ui": {
"page": "options.html"
},
"sidebar_action": {
"default_icon": "favicon.ico",
"default_panel": "sidebar.html"
},
"web_accessible_resources": [
"inject.js"
]
Expand Down
11 changes: 11 additions & 0 deletions test/integration/web-extension/sidebar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<html>

<head>
<script src="sidebar/index.js"></script>
</head>

<body>
</body>

</html>
5 changes: 5 additions & 0 deletions test/integration/web-extension/sidebar/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
main()

function main() {
console.log('Hello, world!')
}
3 changes: 2 additions & 1 deletion test/web-extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ describe('WebExtension', () => {
{ name: 'favicon.ico' },
{ name: 'inject.js' },
{ name: 'options.html' },
{ name: 'popup.html' }
{ name: 'popup.html' },
{ name: 'sidebar.html' }
]
})

Expand Down