In an extension, HTML files serve as the foundation for user interfaces such as popups, options pages, and new tab pages. Extension.js ensures that HTML files defined in the manifest.json
file are correctly processed, with full support for styles, scripts, and static assets.
Extension.js offers first-class support for HTML files, ensuring hot-module replacement (HMR) where applicable. It handles asset injection (images, CSS, JS), live-reloading, and updates.
The following manifest fields use HTML files as entry points:
Manifest Field | File Type Expected | HMR Support |
---|---|---|
action.default_popup |
.html | Yes |
background.page |
.html | Yes |
chrome_settings_overrides.homepage |
.html | Yes |
chrome_url_overrides.newtab |
.html | Yes |
chrome_url_overrides.history |
.html | Yes |
chrome_url_overrides.bookmarks |
.html | Yes |
devtools_page |
.html | Yes |
options_ui.page |
.html | Yes |
page_action.default_popup |
.html | Yes |
sandbox.pages |
.html | Yes |
side_panel.default_panel |
.html | Yes |
sidebar_action.default_panel |
.html | Yes |
Hereβs a basic example of an HTML file used in an extension:
manifest.json
If you need to include additional HTML files that are not declared in the manifest.json
, such as sandboxed iframes or extra pages, you can place these files in the /pages
folder. Extension.js will process the HTML files in this folder as it would for any HTML entry point defined in the manifest.
Example Usage:
Place your HTML file in the /pages
folder, and it will be bundled and available for use, with full support for HMR, asset injection, and other processing steps.
This allows you to add extra pages to your extension without cluttering the manifest or needing to specify them directly there.
For more details, refer to the Special Folders documentation.
The output path for HTML files is always structured as [feature]/index[ext]
. For example, if you're working on a new tab override, the resulting files would look like this:
The plugin for HTML file support in Extension.js ensures that the following steps occur during compilation:
<img>
, <link>
, and <script>
are added to the compilation.pages/
for additional HTML pages outside the scope of the manifest.action.default_popup
and chrome_url_overrides
.