Skip to content

package.json webExt section doesn't support global options for commands #3571

Open

Description

@xM8WVqaG

What is the current behavior?

There is a set of global options (these ones) which can be set on any (?) specific command as an arg.

For example:

  • web-ext run --source-dir dist
  • web-ext lint --ignoreFiles 'dist/**'

This is very useful if you have a compilation step before the extension can be built, so you cannot set source or ignore globally for every command.

However, while they work as arguments, you cannot configure them in the webExt block of package.json.

The following code does not work:

{
  "webExt": {
    "run": {
      "sourceDir": "dist"
    },
    "lint": {
      "ignoreFiles": [
        "dist/**"
      ]
    }
  }
}

When running a command the error is:

UsageError: The config file at /REDACTED/package.json specified an unknown option: "sourceDir"

or

UsageError: The config file at /REDACTED/package.json specified an unknown option: "ignoreFiles"

What is the expected or desired behavior?

It would be useful to be able to set these global options on specific commands, rather than only being able to set them for the entire project.

The current workaround is to spread config between the webExt block and aliasing commands with the correct args as scripts which works but can make debugging tricky as config is now being set in multiple places.

Activity

  1. rpl commented on Dec 18, 2025

    @rpl
    Member

    @xM8WVqaG did you already tried to set the global option outside of the command-specific properties?

    Based on our docs (see here) that should be working instead, if that doesn't work it may be a regression or an issue with some of the global options.

  2. xM8WVqaG commented on Dec 18, 2025

    @xM8WVqaG
    Author

    @xM8WVqaG did you already tried to set the global option outside of the command-specific properties?

    Based on our docs (see here) that should be working instead, if that doesn't work it may be a regression or an issue with some of the global options.

    Thanks for replying. Yes you can set the global options outside the command-specific properties but that doesn't work for my usecase where the run command should only watch the compiled ./dist dir and the lint command should be doing the opposite.

    This ticket is about the inconsistency of only being able to only set these arguments at the project level using the webExt config, when you can set them on a per-command basis if you're calling them directly.

    I'm currently having to workaround this by spreading the config across two places instead of having a single place for config:

    {
      "scripts": {
        // Other scripts removed for noise
        "start:web-ext": "web-ext run --source-dir dist"
        "lint:web-ext": "web-ext lint --ignoreFiles 'dist/**'"
      },
      "webExt": {
        "run": {
          "startUrl": [
            "https://example.com/webext-debug"
          ]
        },
        "lint": {
          "warningsAsErrors": true
        },
      }
    }
  3. Rob--W commented on Jan 15, 2026

    @Rob--W
    Member

    This is a reasonable feature request. The option parsing logic is complicated (a combination of custom parsing and relying on yargs), but if a patch were to be provided that implements this in a reasonable way, we'd accept patches.

    In the meantime, the work around is to pass the command specific options via the command line rather than the config file, as seen in the last comment above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions