Manifest
Learn how to configure the manifest of your extension.
As a requirement from web stores, every extension must have a manifest.json
file in its root directory that lists important information about the structure and behavior of that extension.
It's a JSON file that contains metadata about the extension, such as its name, version, and permissions.
You can read more about it in the official documentation.
Where is the manifest.json
file?
Plasmo abstracts away the manifest file. The framework generates the manifest under the hood based on your source files and configurations you export from your code, similar to how Next.js abstracts page routing and SSG with the file system and page components.
That way, you don't have to manually create the manifest.json
file and worry about correctly setting all the fields.
Most of the common properties are taken from the package.json
file:
Manifest Field | Abstractions |
---|---|
icons | Auto generated with the icon.png in the /assets directory |
action, browser_actions | Popup window |
options_ui | Options page |
content_scripts | Content scripts |
background | Background service worker |
manifest_version | set by the --target build flag, default to 3 |
version | set by the version field in package.json |
name | set by the displayName field in package.json |
description | set by the description field in package.json |
author | set by the author field in package.json |
homepage_url | set by the homepage field in package.json |
Plasmo centralizes common metadata between package.json
and manifest.json
and resolves any static file references (such as popup, background, content scripts, and so on) automatically.
This enables you to focus on the metadata that matters, such as name, description, OAuth, declarative_net_request, and so on.
Overriding manifest
Sometimes, you want to override the default manifest fields (e.g. because you need to add a new permission that is required for your extension to work).
You'll need to modify your project's package.json
like so:
Then, your settings will be merged with the settings auto-generated by Plasmo.
Environment variables
You can use environment variables inside the manifest overrides:
If the environment variable could not be found, the field will be removed completely from the manifest.
Locales
TurboStarter extension supports localization out-of-the-box. You can customize e.g. your extension's name and description based on the language of the user's browser.
Locales are defined in the /locales
directory. The directory should contain a messages.json
file for each language you want to support (e.g. /locales/en/messages.json
and /locales/es/messages.json
).
By default, Plasmo picks the first locale alphabetically available as default. However, you can specify a default_locale
in your manifest like so:
To reference a locale string inside your manifest overrides, wrap the key inside __MSG_<key>__
:
Last updated on