0.1.0 • Published 3 years ago

webpack-open-chrome-extension v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

webpack-open-chrome-extension workflow npm

Programatically open a web extension in a Chrome browser via webpack plugin

Loads a WebExtension in a new browser instance with a new profile for each run with configurable options via webpack config.

Highlights

  • No executable downloads. Locates and uses the system installed binary.
  • Loads the extension in a clean state by default by providing a fresh profile for every run (customizable).
  • No extra step to open/close Chrome. Killing the webpack dev server instance also kills the browser process.
  • Allows additional Chrome flags via options config. Full support to virtually all Chrome flags.
yarn add webpack-chrome-extension-launcher -D

Usage

See webpack.config.js example.

new WebpackOpenChromeExtension({
  extensionPath: 'path/to/extension',
  chromeFlags: [
    '--enable-experimental-extension-apis',
    '--embedded-extension-options'
  ],
  userDataDir: 'path/to/user/data/dir',
  startingUrl: 'https://example.com'
})
+ const WebpackOpenChromeExtension = require('webpack-open-chrome-extension')

module.exports {
  plugins: [
+   new WebpackOpenChromeExtension({
+     extensionPath: 'path/to/extension',
+     chromeFlags: [
+       '--enable-experimental-extension-apis',
+       '--embedded-extension-options'
+     ],
+     userDataDir: 'path/to/user/data/dir',
+     startingUrl: 'https://example.com'
+   })
  ]
}

API

new WebpackOpenChromeExtension(options)

Options

extensionPath (required)

Type: string

Path to your extension. Must point to the same directory as the manifest file.

chromeFlags (optional)

Type: Array<string>

Additional flags to pass to Chrome. Defaults to these flags.

For a full list of available flags, see https://peter.sh/experiments/chromium-command-line-switches/.

userDataDir (optional)

Type: string | boolean

What Chrome profile path to use. A boolean value of false sets the profile to the default user profile. Defaults to a fresh Chrome profile.

startingUrl (optional)

Type: string

What URL to start the browser with. Defaults to about:blank

License

MIT (c) Cezar Augusto.