extension-js / extension.js

🧩 Plug-and-play, zero-config, cross-browser extension development tool.
https://extension.js.org
MIT License
3.67k stars 93 forks source link

Add extension.config.js support #144

Closed cezaraugusto closed 1 month ago

cezaraugusto commented 1 month ago

The ability to extend config beyond of what Extension.js can provide is our current most wanted feature. I'm also looking for ways to reduce the program size and having optional modules installed via config rather than built-in an this seems the best way to get there.

To extend Extension.js, users would add a "extension.config.js" at the root of their project and install their dependencies.

The schema looks like the below. In the future we will also have the command line arguments defined:

/** @type {import('extension-develop').ConfigFile} */
module.exports = {
  config: (config) => {
    config.module.rules.push({
      test: /\.svg$/i,
      issuer: /\.[jt]sx?$/,
      // exclude react component if *.svg?url
      resourceQuery: {not: [/url/]},
      use: [require.resolve('@svgr/webpack')]
    })

    return config
  }
}
cezaraugusto commented 1 month ago

cc @OSpoon to review this one I added an example config-extension-config which uses SVGR. Please review when you get a chance.

cc @wjureczka the example is based on your suggestion in https://github.com/extension-js/extension.js/issues/126 and cc @0xBigBoss this should address your feedback in https://github.com/extension-js/extension.js/issues/142. Free to take a look at the code and suggest improvements/review this PR.

cezaraugusto commented 1 month ago

FYI this will be included in the next release (v2.0.0) once #146 is ready