https://github.com/serguun42/webpack-service-worker-plugin
A plugin used to minify, link and build Service Worker for Webpack.
https://github.com/serguun42/webpack-service-worker-plugin
service-worker serviceworker webpack
Last synced: 3 months ago
JSON representation
A plugin used to minify, link and build Service Worker for Webpack.
- Host: GitHub
- URL: https://github.com/serguun42/webpack-service-worker-plugin
- Owner: serguun42
- License: bsl-1.0
- Created: 2022-09-15T15:07:35.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-10-14T12:18:17.000Z (over 2 years ago)
- Last Synced: 2025-01-23T09:11:32.748Z (5 months ago)
- Topics: service-worker, serviceworker, webpack
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@serguun42/webpack-service-worker-plugin
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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`:
```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`_):```javascript
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](./LICENSE)