noop-service-worker-middleware
v3.0.0
Published
Returns Express middleware that serves a service worker that resets any previously set service worker configuration. Useful for development.
Downloads
129
Readme
noop-service-worker-middleware
Returns Express middleware that serves a service worker that resets any previously set service worker configuration. Useful for development.
Installation
npm i -D noop-service-worker-middleware
API
const noopServiceWorkerMiddleware = require("noop-service-worker-middleware");
noopServiceWorkerMiddleware(path)
Returns Express middleware that serves a service worker that resets any previously set service worker configuration.
Options
path
Filename of service worker.
app.use(noopServiceWorkerMiddleware("/custom-service-worker.js"));
Examples
Simple
const express = require("express");
const noopServiceWorkerMiddleware = require("noop-service-worker-middleware");
const app = express();
app.use(noopServiceWorkerMiddleware());
app.get("/", (req, res) => {
res.send("hello, world!");
});
Webpack Dev Server
const noopServiceWorkerMiddleware = require("noop-service-worker-middleware");
module.exports = {
// ...
devServer: {
before(app, server) {
app.use(noopServiceWorkerMiddleware());
}
// ...
}
// ...
};
Thanks
- create-react-app - inspiration.