javascriptjsongoogle-chromegoogle-chrome-extension

Chrome Extension - manifest.json load all js in folder


I'm making a Chrome extension, which will run some tests and I need to be able to change those tests by adding a new js file for each test inside the folder tests, so I tried to use this on my manifest:

"content_scripts": [
    {
      "matches": ["*://mysite.com/*"],
      "js": [
        "content.js",
        "tests/*.js"
      ],
      "run_at": "document_end"
    }
  ]

But Chrome throws an error when uploading this manifest. Is there any other way to do this?


Solution

  • Can't do that, you need to explicitly list all the scripts.

    Your best bet is to have some sort of build script that updates the manifest.json itself, or combines scripts into a bigger one you can explicitly include.