Icons are used in various parts of the extension interface, including the toolbar, context menus, and the extension settings. Extension.js ensures that all icons defined in the manifest.json
file are correctly processed and emitted to the output directory during the build process.
Extension.js provides comprehensive support for handling icon files. It supports standard image formats such as .png
, .jpg
, and .svg
. All icons referenced in the manifest.json
are included in the build and served as required by the extension's context.
The following manifest fields use icons:
Manifest Field | File Type Expected | HMR Support |
---|---|---|
action.default_icon |
.png, .jpg, .svg | Yes |
browser_action.default_icon |
.png, .jpg, .svg | Yes |
icons |
.png, .jpg, .svg | Yes |
page_action.default_icon |
.png, .jpg, .svg | Yes |
sidebar_action.default_icon |
.png, .jpg, .svg | Yes |
manifest.json
Hereβs a basic example of how to declare icons in your manifest.json
:
This configuration ensures that Extension.js will process and emit the icons to the appropriate location in the output directory during the build process.
If you have additional icons that are not directly declared in the manifest.json
, such as theme icons or extra icons for specific contexts, you can place these icons in the /public
folder. Extension.js will include these files in the build output as-is, ensuring they are accessible for use throughout your extension.
Example Usage:
Place your icons in the /public/icons
folder:
For more information, refer to the Special Folders documentation.
The output path for icons follows a simple structure based on their context in the manifest. For example, the resulting files would look like this:
The plugin responsible for icon handling in Extension.js ensures that the following steps occur during compilation:
manifest.json
are emitted to the output directory..png
, .jpg
, and .svg
./public/
folder for additional icons that are not directly declared in the manifest.manifest.json
file to ensure proper inclusion in the build process.16px
, 48px
, 128px
).