@serguun42/webpack-service-worker-plugin
TypeScript icon, indicating that this package has built-in type declarations

1.1.3 • Public • Published

Webpack Service Worker Plugin

Plugin used to minify, link and build Service Worker for Webpack. Unlike workbox-webpack-plugin, this plugin's primary task is to compile existing Service Worker with all plugins – not to generate new SW or inject chunks of boilerplate code.

Usage

Suitable for webpack v4 and webpack v5. From package.json:

"peerDependencies": {
  "webpack": "^4.4.0 || ^5.9.0"
}
  1. Install – npm i @serguun42/webpack-service-worker-plugin.
  2. Add to webpack config's plugins section (usually webpack.config.js):
const WebpackSWPlugin = require("@serguun42/webpack-service-worker-plugin");

module.exports = {
	entry: "…",
	output: {
		path: "…",,
		filename: "…",
	},
	
	plugins: [
		,
		new WebpackSWPlugin({
			/** Relative to project's root */
			source: "src/service-worker.js",
			/** Relative to build/dist folder */
			output: "js/sw.js"
		}),
		
	]
}

Config/params

name description/type default
source Path of Service Worker entry file relative to project's root src/service-worker.js
output Path of minified, linked and built Service Worker file inside relative to build folder service-worker.js

In general can be used to side-compile any non-SW code, just change these two parameters.


BSL-1.0 License

Readme

Keywords

Package Sidebar

Install

npm i @serguun42/webpack-service-worker-plugin

Weekly Downloads

0

Version

1.1.3

License

BSL-1.0

Unpacked Size

8.02 kB

Total Files

7

Last publish

Collaborators

  • serguun42