1.0.0 • Published 3 years ago

webpack-resolve-background-script v1.0.0

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

webpack-resolve-background-script workflow npm

Resolve background scripts defined in a WebExtension manifest file

Allows a WebExtension to link to background scripts defined the manifest file even after compilation. If your webpack config needs to copy the extension manifest to the output folder, this plugin ensures background scripts point to the right path.

How it works

Before compilation

Directory

./yourWebExtension/
├── public
│   └── manifest.json
└── src
    └── background.js

Manifest

{
  "manifest_version": 2,
  "name": "Your browser extension",
  "version": "1.0",
  "background": {
    "scripts": [ "../src/background.js" ]
  }
}

After compilation

Directory

./yourWebExtension
├── background.js
└── manifest.json

Manifest

{
  "manifest_version": 2,
  "name": "Your browser extension",
  "version": "1.0",
  "background": {
    "scripts": [ "./background.js" ]
  }
}

Usage

See webpack.config.js example.

const WebpackResolveBackgroundScript = require('webpack-resolve-background-script')

module.exports {
  plugins: [
    new WebpackResolveBackgroundScript(/* <path-to-dist-manifest-file> */)
  ]
}

API

new WebpackResolveBackgroundScript(manifestDistFilePath)

manifestDistFilePath

Type: string

Path to your webExtension manifest file after compilation.

License

MIT (c) Cezar Augusto.