serviceworker-webpack-plugin
Simplifies creation of a service worker to serve your webpack bundles.
Installation
npm i serviceworker-webpack-plugin-martiuh
It's only compatible with webpack 1, 2, and 3
The simple truth
First of all, this a simple fork, it only adds a feature necessary for a project I'm doing, which is scriptURL
it can now be set manually and the service worker will try to be installed from that specific directory.
All the work is to oliviertassinari and the amazing serviceworker-webpack-plugin
API
ServiceWorkerWebpackPlugin(options)
options
-
entry
, required, string: Path to the actual service worker implementation. -
filename
, string, default'sw.js'
: Relative (from the webpack's configoutput.path
) output path for emitted script. -
excludes
, array, default['**/.*', '**/*.map']
: Exclude matched assets from being added to theserviceWorkerOption.assets
variable. (Blacklist) -
includes
, array, default['**/*']
: Include matched assets added to theserviceWorkerOption.assets
variable. (Whitelist) -
publicPath
, string, default'/'
: Specifies the public URL address of the output files when referenced in a browser. -
outputDir
: If you want your serviceWorker file to be stored in a aditional folder inside webpack's output path. -
template
, function, default noop: This callback function can be used to inject statically generated service worker. It's taking aserviceWorkerOption
argument and must return a promise. -
transformOptions
, function: ThejsonStats
key contains all the webpack build information.
runtime(options)
-
options
: That's forwarded to theoptions
argument of theServiceWorkerContainer.register()
function.
Credit
- The offline-plugin package was a great source of inspiration.
- The html-webpack-plugin package was also really helpful.
The specs
License
MIT