1.1.3 • Published 2 years ago

@serguun42/webpack-service-worker-plugin v1.1.3

Weekly downloads
-
License
BSL-1.0
Repository
github
Last release
2 years ago

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

namedescription/typedefault
sourcePath of Service Worker entry file relative to project's rootsrc/service-worker.js
outputPath of minified, linked and built Service Worker file inside relative to build folderservice-worker.js

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


BSL-1.0 License