Movatterモバイル変換


[0]ホーム

URL:


Extension Workshop

Submit or Manage Extensions
Contents
  1. Commands
  2. Global options
  3. Setting option environment variables
  4. See also

Commands

web-ext has the following commands; options specific to these commands are included as subsections.

web-ext build

Packages an extension into a.zip file, ignoring files that are commonly unwanted in packages, such as.git and other artifacts. The name of the.zip file is taken from thename field in the extensionmanifest.

--as-needed

Re-build the extension anytime you edit and save a source file. This allows you to continuously create a package with the most up to date source code.

Environment variable:$WEB_EXT_AS_NEEDED=true

--overwrite-dest,-o

Overwrite destination package file if it exists. Without this option, web-ext will exit in error if the destination file already exists.

Environment variable:$WEB_EXT_OVERWRITE_DEST=true

--filename,-n

Name of the created extension package file. In this option, the values defined inmanifest.json can be used by enclosing them with{ }. The default value is{name}-{version}.zip.

Environment variable:$WEB_EXT_FILENAME

web-ext docs

Opens theweb-ext documentation in the user's default browser.

web-ext lint

Reports errors in the extensionmanifest or other source code files. Whenstrict_min_version is set in your extension’s manifest file, lint will report on the permissions, manifest keys, and web extension APIs used that are not available in that version. See theaddons-linter project for more information about what kind of rules are used to validate extension source.

--output,-o

The type of output to generate when reporting on errors. Choices:json ortext.

Environment variable:$WEB_EXT_OUTPUT

--metadata

Output only metadata about the extension in JSON.

Environment variable:$WEB_EXT_METADATA=true

--pretty

Format the JSON output so that it's easier to read. This only applies when--output is set tojson.

Environment variable:$WEB_EXT_PRETTY=true

--self-hosted

Declares that your extension will be self-hosted. This disables messages related to hosting onaddons.mozilla.org.

Environment variable:$WEB_EXT_SELF_HOSTED=true

--boring

Disables colorful shell characters so that the output only contains plain text.

Environment variable:$WEB_EXT_BORING=true

--warnings-as-errors,-w

Treat warnings as errors by exiting non-zero for warnings.

Environment variable:$WEB_EXT_WARNINGS_AS_ERRORS=true

--firefox-preview

Turn on developer preview features in Firefox. This option accepts multiple values, depending on the available developer previews.

This option was added in web-ext 7.3.0.

web-ext run

Builds and then temporarily installs an extension on the target application, so it can be tested. By default, watches extension source files and reload the extension in each target as files change.

--adb-bin

Path to theADB (Android Device Bridge) executable on the machine you are runningweb-ext from. By default, theadb executable will be located on yourPATH.

Environment variable:$WEB_EXT_ADB_BIN

--adb-device,--android-device

The ID of your target Android device. If you do not specify this option,web-ext will list the IDs of each device connected. If you don't see a list of connected devices, make sureyours is set up for development.

Example:

web-ext run--target=firefox-android --android-device FA4AX0201736

Environment variable:$WEB_EXT_ADB_DEVICE

--adb-host

Host name to use when connecting to an Android device withADB (Android Device Bridge). This will be discovered automatically by default.

Environment variable:$WEB_EXT_ADB_HOST

--adb-port

Network port to use when connecting to an Android device withADB (Android Device Bridge). This will be discovered automatically by default.

Environment variable:$WEB_EXT_ADB_PORT

--adb-remove-old-artifacts

web-ext automatically removes all the temporary files that were written to the target adb device when it does exit. This may fail, for example when the device is disconnected before
web-ext run exited.

Starting from v5.0.0,web-ext run will automatically detect and warn the user if old artifacts have been found on the adb device, but it does not automatically remove them by default.

This flag forces web-ext to automatically remove these discovered artifacts.

Environment variable:$WEB_EXT_ADB_REMOVE_OLD_ARTIFACTS

--browser-console,-bc

This opens aBrowser Console on startup, so you can see log messages for your extension. Example:

web-ext run --browser-console

Environment variable:$WEB_EXT_BROWSER_CONSOLE=true

Note: The browser console may not show all debugging output from content-scripts. Use the web console when debugging content-scripts.

--devtools

This opens the Developer Tools for the installed extension on startup. Seethis documentation for more information. Example:

web-ext run--devtools

Note: The opened Developer Tools may not show all debugging output from content-scripts. Use the web console when debugging content-scripts.

This option was added in web-ext 7.3.0 and it requires Firefox 106 and newer.

--firefox,-f

Specify a particular version ofFirefox Desktop to run the extension in. The value is an absolute path to the Firefox executable or an alias string. If this is not specified, it will attempt to run the extension inside the system's default installation of Firefox.

Here is an example specifying a full path to a Firefox executable on Windows:

--firefox="C:\Program Files\Mozilla Firefox\firefox.exe"

Here is an example specifying an executable path on Mac OS:

--firefox=/Applications/FirefoxNightly.app/Contents/MacOS/firefox-bin

You can also use aliases, like this:

--firefox=beta

Here are all available aliases and the executables they map to:

AliasFirefox executable
firefoxTherelease build of Firefox
betaThebeta build of Firefox
nightlyThenightly build of Firefox
deved orfirefoxdevelopereditionThedeveloper build of Firefox

As of web-ext 7.2.0,Flatpak users can use this option with the valueflatpak:org.mozilla.firefox (whereorg.mozilla.firefox isthe Flatpak application ID for Firefox on Flathub):

web-ext run--firefox=flatpak:org.mozilla.firefox

Environment variable:$WEB_EXT_FIREFOX

--firefox-apk

The exactAPK name forFirefox on your Android device. Without specifying this option,web-ext will automatically select it for you. If more than one Firefox APK is installed,web-ext will show a list of values to choose from.

Example:

web-ext run--target=firefox-android --firefox-apk=org.mozilla.firefox

Environment variable:$WEB_EXT_FIREFOX_APK

--firefox-preview

Turn on developer preview features in Firefox. This option accepts multiple values, depending on the available developer previews.

This option was added in web-ext 7.1.0.

--firefox-profile,-p

Specify a base Firefox profile to run the extension in. This is specified as a string containing your profile name or an absolute path to its directory. The profile you specify is copied into a new temporary profile and some settings are added that are required forweb-ext to function.

If a profile is not specified, it runs the extension using a new temporary profile.

Environment variable:$WEB_EXT_FIREFOX_PROFILE

--profile-create-if-missing

With this option, the profile directory (specified by the--firefox-profile or--chromium-profile options) will be created if it does not exist yet.

When this option is specified, the--firefox-profile option is always treated as a directory path.

Environment variable:$WEB_EXT_PROFILE_CREATE_IF_MISSING

--keep-profile-changes

With this option, any changes made to the profile directory (specified by--firefox-profile) are saved. Without this option, profile changes are not saved.

This option makes the profile specified by--firefox-profile completely insecure for daily use. It turns off auto-updates and allows silent remote connections, among other things. Specifically, it will make destructive changes to the profile that are required forweb-ext to operate.

Environment variable:$WEB_EXT_KEEP_PROFILE_CHANGES=true

--no-reload

Do not automatically reload the extension in the browser as you edit and save source files.

Environment variable:$WEB_EXT_NO_RELOAD=true

--pre-install

Pre-install the extension into the profile before starting the browser. This is a way to support Firefox versions less than 49, as they don't support remote installation. Specifying this option implies--no-reload.

Environment variable:$WEB_EXT_PRE_INSTALL=true

--pref

Customize any Firefox preference without creating or modifying the profile. Use the equal sign to set values, for example:

--prefgeneral.useragent.locale=fr-FR

Specify this option multiple times to set more than one preference.

Environment variable:$WEB_EXT_PREF

--target,-t

This specifies which application to run your extension in. Specify this option multiple times to run the extension in each application concurrently.

Here are the supported targets:

TargetApplication
firefox-desktopThe extension will run inFirefox Desktop.
firefox-androidThe extension will run inFirefox for Android. You must also specify--android-device.
chromiumThe extension will run in a Chromium-based browser. You can specificy exact binary with--chromium-binary.

If no target is specified, the extension will run infirefox-desktop.

Environment variable:$WEB_EXT_TARGET

--args,--arg

Additional CLI options passed to the Browser binary. Example:

web-ext run--arg="--search=mozilla"--arg="--new-tab=https://duckduckgo.com"
web-ext run--arg="--remote-debugging-port=9229"--target chromium

--chromium-binary

Path or alias to a Chromium executable such as google-chrome, google-chrome.exe or opera.exe etc.
If not specified, the default Google Chrome will be used.

--chromium-profile

Path to a custom Chromium profile.

--start-url

This will open a tab at the specified URL when the browser starts. Example:

web-ext run --start-url www.mozilla.com

Declare this option multiple times to open multiple tabs. Example:

web-ext run --start-url www.mozilla.com --start-url developer.mozilla.org

Environment variable:$WEB_EXT_START_URL

--watch-file,--watch-files

A list of files that should be watched for changes. This is useful if you want web-ext to explicitly watch for changes to specific files, without watching the extension directory tree, e.g. the output of the build from a module bundler.

web-ext run --watch-file dist/background.js dist/content-script.js

--watch-ignored

A list of paths and globs patterns that should not be watched for changes. This is useful if you want to explicitly prevent web-ext from watching part of the extension directory tree, e.g. the node_modules folder.

web-ext run --watch-ignored dir1/to/file.js dir2/*.js dir3/**

This option is useful to prevent issues when the number of watched files is higher than what the underlying OS feature allows. As an example, on Linux aError: ENOSPC: System limit for number of file watchers reached exception is raised if too many files are being watched (Seeweb-ext#2022).

web-ext sign

This command uses theaddons.mozilla.org API to sign your extension. If successful, it will download the signed.xpi file, which you can use toself-host your extension.

You need to createAPI access credentials to run this command.Obtain your personal access credentials here.

--use-submission-api

Use the experimentaladdons.mozilla.org add-on submission API, rather than theaddons.mozilla.org signing API to sign your extension. This allows listed versions to be freely created by enabling all necessary additional metadata to be submitted at the same time as the extension file.

With this option enabled,--channel changes to be a required option with no default. The choices remainlisted andunlisted.

Environment variable:$WEB_EXT_USE_SUBMISSION_API

This option was added in web-ext 7.3.1.

--api-key

Your API key (JWT issuer) for accessing theaddons.mozilla.org API. This should always be a string.

Environment variable:$WEB_EXT_API_KEY

--api-secret

Your API secret (JWT secret) fromaddons.mozilla.org API. This should always be a string.

Environment variable:$WEB_EXT_API_SECRET

--api-url-prefix

The signing API URL prefix. This should always be a string. If not specified, this will default to https://addons.mozilla.org/api/v4 which is the production API.

This option is ignored when--use-submission-api is used. See--amo-base-url instead.

Environment variable:$WEB_EXT_API_URL_PREFIX

--amo-base-url

The add-on submission API base URL. This should always be a string. If not specified, this will default to https://addons.mozilla.org/api/v5 which is the production API.

This option is only used when--use-submission-api is used. See--api-url-prefix instead.

Environment variable:$WEB_EXT_AMO_BASE_URL

--api-proxy

A proxy host to use for all API connections. Example:https://yourproxy:6000.Read more abouthow proxy requests work. There is a separate section aboutsigning in a restricted environment if the proxy approach doesn't work for you.

Environment variable:$WEB_EXT_API_PROXY

--channel

This specifies thechannel in which the extension is signed. It defaults tounlisted or thechannel of your extension's latest version. When the--use-submission-api option is specified the behaviour of--channel - and the limitations - are quite different than explained here: see the documentation for--use-submission-api above for more information.

The allowed values forchannel are:

ChannelResult
listedThe extension gets submitted for public listing onaddons.mozilla.org. This type of channel is not well supported and cannot be used for some cases, as documented below.
unlistedThe extension gets submitted for signing for the purpose ofself-distribution on your own website.

One example of using the--channel option is tocreate a beta version for alisted extension (that is, one you have alreadysubmitted to addons.mozilla.org).

Setting--channel=listed for a new extension is not yet supported. Seehttps://github.com/mozilla/web-ext/issues/804

Setting--channel=listed for a new version of a listed extension is not well supported. It will upload your new version toaddons.mozilla.org as if you'dsubmitted it manually. However, the command will fail and you'll have to checkaddons.mozilla.org/developers/addons for the correct status.

Seedocumentation on the signing API for more information.

Environment variable:$WEB_EXT_CHANNEL

--timeout

Number of milleseconds to wait before giving up on a response from Mozilla's web service. This should always be a number.Defaults to 5 minutes (300000 ms)

Environment variable:$WEB_EXT_TIMEOUT

--id

A custom identifier string for the extension. This has no effect if the extension already declares an identifier in its manifest. This option may be useful for signing versions of an existing extension that you own.

This option cannot be used when--use-submission-api is also used: the add-on ID must be specified in themanifest.json file.

Environment variable:$WEB_EXT_ID

--amo-metadata

Path to a JSON file containing an object with metadata to be passed to the add-on submission API. Typically this is used to submit the required metadata for the first listed version of an extension (e.g.categories;license), but anysupported JSON metadata can be supplied.

This option is only used when combined with--use-submission-api.

Environment variable:$WEB_EXT_AMO_METADATA

Global options

web-ext has the following global options that may apply to multiple commands.

--artifacts-dir,-a

Specifies a particular directory to save artifacts in, e.g. the.zip file, once you've built an extension. This can be specified as a relative or absolute path, and should always be a string.

If this is not specified, the default is the relative path./web-ext-artifacts.

Environment variable:$WEB_EXT_ARTIFACTS_DIR

--config,-c

Load a config file to set option value defaults. See an example ofwhat config files look like and how they work.

Environment variable:$WEB_EXT_CONFIG

--config-discovery=false,--no-config-discovery

Disableautomatic config file discovery.

Environment variable:$WEB_EXT_CONFIG_DISCOVERY=false or$WEB_EXT_NO_CONFIG_DISCOVERY

--ignore-files,-i

A list ofglob patterns to define which files should be ignored bybuild,run,lint and other commands. If you specify relative paths, they will be relative to your--source-dir.

Here is an example of ignoring any file within your--source-dir (or its subdirectories) that ends in the suffix.api-key:

web-ext build --ignore-files"\*_/_.api-key"

You can specify multiple patterns by separating them with spaces:

web-ext build --ignore-files path/to/first.js path/to/second.js

By default, without the use of--ignore-files, the following rules are applied:

  • Any file ending in.xpi or.zip is ignored
  • Any hidden file (one that starts with a dot) is ignored
  • Any directory namednode_modules is ignored

When you specify custom patterns using--ignore-files, they are appliedin addition to the default patterns.

Order is important! You must specify the web-ext command before specifying the--ignore-files option.

Environment variable:$WEB_EXT_IGNORE_FILES

--help,-h

Lists all the available commands and options available for the web-ext tool.

You can list the options available for a specific command by including the command name as you request help, for exampleweb-ext --help run.

--no-input

Disable all features that require standard input.

Environment variable:$WEB_EXT_NO_INPUT=true

--source-dir,-s

Specifies the directory of the extension's source code, e.g. when building or running an extension. This can be specified as a relative or absolute path, and should always be a string.

If this is not specified, the default is the directory you are currently inside in your terminal.

Environment variable:$WEB_EXT_SOURCE_DIR

--verbose,-v

Shows verbose output when commands are run.

Environment variable:$WEB_EXT_VERBOSE=true

--version

Shows the version number of the installed web-ext tool.

Setting option environment variables

Environment variables can be set for any option. You:

  1. Take the option name.
  2. Remove the two dashes at the start.
  3. Convert the remaining dashes to underscores.
  4. Capitalize the letters.
  5. Prefix the result with$WEB_EXT_.

So, for example, instead of specifying the following source option every time you wish to run the extension:

web-ext run --source-dir=/path/to/my/extension

You could set the source directory as an environment variable like this:

WEB_EXT_SOURCE_DIR=/path/to/my/extension

Then you can just specify the run command without options:

web-ext run

A command line option will always override the environment variable. For example, this ignores the environment variable:

web-ext run --source-dir=/another/path/to/source

To define atrue /false flag option (which does not have a value on the command line), set it to a literal string value of eithertrue orfalse. Example:

WEB_EXT_VERBOSE=true

See also

Tags: commands options reference tools web-ext webextensions 

Contributors: akhilpanchal andrewtruongmoz aniketkudale ankushduacodes ankushduacodes chrisdavidmills Dietrich eviljeff groovecoder hamatti kumar303 lfilho LowerDimensions niharikak101 noraj rebloor Rob--W saintsebastian sharang smile4ever tofumatt wbamberg willdurand djbrown Robot-Inventor 

Last update:  

Up Next

Develop

Extensions and the Add-on ID

Develop

Build a secure extension

Develop

Request the right permissions
Documentation Topics

Connect With Us

Twitter

For developers:
@mozamo

For end users:
@rockyourfirefox

More

Matrix

Community forum

Extensions Developer Newsletter

Stay up-to-date on news and events for Firefox extension developers.

Thanks! Please check your inbox to confirm your subscription.

If you haven’t previously confirmed a subscription to a Mozilla-related newsletter you may have to do so. Please check your inbox or your spam filter for an email from us.


[8]
ページ先頭

©2009-2025 Movatter.jp