JSON in browser extensions provide data for rulesets, managed storage schemas, and more. Extension.js handles the inclusion, bundling, and processing of JSON files referenced in the manifest.json
, ensuring they are correctly emitted and added to the compilation output.
Extension.js supports handling JSON files defined in the manifest.json
, ensuring that they are processed and output correctly. This includes rulesets for declarative network requests and storage-managed schemas. The following manifest fields are supported:
Manifest Field | File Type Expected | HMR Support |
---|---|---|
declarative_net_request.rule_resources |
.json | Yes |
storage.managed_schema |
.json | Yes |
manifest.json
Hereβs an example of how to declare a JSON file in your manifest.json
:
This configuration ensures that Extension.js will process the JSON files and include them in the final output of your extension.
If you have additional JSON files that are not directly declared in the manifest.json
, such as extra configuration or data files, you can place these JSON files 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 JSON files in the /public/json
folder:
For more information, refer to the Special Folders documentation.
The output path for JSON files follows a simple structure based on their context in the manifest. For example, the resulting files would look like this:
The plugin responsible for handling JSON files in Extension.js ensures that the following steps occur during compilation:
manifest.json
are emitted to the output directory./public/
folder for additional JSON files that are not directly declared in the manifest.