Skip to content

Commit

Permalink
Provide a no-op SW that will be served by the dev environment. (faceb…
Browse files Browse the repository at this point in the history
…ook#2276)

* Provide a no-op SW that will be served by the dev environment.

* Hide no-op service worker from user
  • Loading branch information
jeffposnick authored and gaearon committed May 20, 2017
1 parent fac6819 commit af87e2e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions config/webpackDevServer.config.js
Expand Up @@ -11,6 +11,7 @@
'use strict';

const errorOverlayMiddleware = require('react-error-overlay/middleware');
const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
const config = require('./webpack.config.dev');
const paths = require('./paths');

Expand Down Expand Up @@ -90,6 +91,12 @@ module.exports = function(proxy, allowedHost) {
setup(app) {
// This lets us open files from the runtime error overlay.
app.use(errorOverlayMiddleware());
// This service worker file is effectively a 'no-op' that will reset any
// previous service worker registered for the same host:port combination.
// We do this in development to avoid hitting the production cache if
// it used the same host and port.
// https://github.com/facebookincubator/create-react-app/issues/2272#issuecomment-302832432
app.use(noopServiceWorkerMiddleware());
},
};
};

0 comments on commit af87e2e

Please sign in to comment.