Warning: This feature is a work in progress and may be incomplete or subject to change. If you see an error or something that could be improved, please make a pull-request. The link that documents this feature can be found at the bottom of the page.
The build
command in Extension.js is responsible for compiling your extension for production.
This command creates optimized builds for different browsers, ensuring compatibility and performance.
The build/
folder will contain subfolders for each targeted browser, each with the necessary code transforms and optimizations.
During the build process, the following steps take place:
--zip
flag is passed, the build output will be packaged into a zip file for easy distribution to the browserβs extension store.To use the build
command, run:
After running the build
command, Extension.js generates optimized files for the specified browser.
You will find the output inside the build/
folder, with separate subfolders for each browser (Chrome, Edge, etc.).
These folders contain the bundled JavaScript, CSS, HTML, and other necessary assets for the extension to work in the targeted environment.
Example Output Structure:
Flag | Argument | What it does | Defaults to |
---|---|---|---|
[path or url] |
The extension path or the remote extension URL | If a path is defined, builds the local extension. If a URL is provided, pulls the extension from remote source and builds it as a local extension | process.cwd() |
-b, --browser |
The browser that will run the extension | Specifies the browser to build for (chrome , edge , all ) |
"chrome" |
--zip-filename |
String | Sets a custom filename for the output zip file | extension.zip |
--zip |
Boolean | Enables zipping of the build output | false |
--zip-source |
Boolean | Zips the source code alongside the build artifacts | false |
--polyfill |
Boolean | Enables polyfill for older browsers | false |
--silent |
Boolean | Suppresses build logs for cleaner output | false |
In this example, the build will target Edge and Chrome, with the output zipped and saved as my-extension.zip
.
Here, the build is for Chrome, and the --silent
flag is used to suppress logs for a clean output.
In this example, the build targets all supported browsers and includes polyfills for legacy compatibility.
manifest.json
is optimized and fully compatible with all targeted browsers to avoid build issues.--zip-filename
option, which is useful for organizing builds.extension.config.js
file to configure your extension.