Skip to content

Commit af87e2e

Browse files
jeffposnickgaearon
authored andcommitted
Provide a no-op SW that will be served by the dev environment. (facebook#2276)
* Provide a no-op SW that will be served by the dev environment. * Hide no-op service worker from user
1 parent fac6819 commit af87e2e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

config/webpackDevServer.config.js

+7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
'use strict';
1212

1313
const errorOverlayMiddleware = require('react-error-overlay/middleware');
14+
const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
1415
const config = require('./webpack.config.dev');
1516
const paths = require('./paths');
1617

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

0 commit comments

Comments
 (0)