0.3.1 • Published 7 years ago
serviceworker-webpack-plugin-martiuh v0.3.1
serviceworker-webpack-plugin
Simplifies creation of a service worker to serve your webpack bundles.
Installation
npm i serviceworker-webpack-plugin-martiuhIt'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)
optionsentry, 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.assetsvariable. (Blacklist)includes, array, default['**/*']: Include matched assets added to theserviceWorkerOption.assetsvariable. (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 aserviceWorkerOptionargument and must return a promise.transformOptions, function: ThejsonStatskey contains all the webpack build information.
runtime(options)
options: That's forwarded to theoptionsargument 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