mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-04-23 20:51:12 +08:00
Disable service worker by default (#3817)
* WIP disable service worker by default (#2554) * Updated service worker registration * Readd default export in registerServiceWorker.js * Updated comments about using Service Worker * Call it serviceWorker * Nits
This commit is contained in:
committed by
Dan Abramov
parent
864874bfa8
commit
0e51eef6d7
8
packages/react-scripts/template/src/index.js
vendored
8
packages/react-scripts/template/src/index.js
vendored
@@ -2,7 +2,11 @@ import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import './index.css';
|
||||
import App from './App';
|
||||
import registerServiceWorker from './registerServiceWorker';
|
||||
import * as serviceWorker from './serviceWorker';
|
||||
|
||||
ReactDOM.render(<App />, document.getElementById('root'));
|
||||
registerServiceWorker();
|
||||
|
||||
// If you want your app to work offline and load faster, you can change
|
||||
// unregister() to register() below. Note this comes with some pitfalls.
|
||||
// Learn more about service workers: http://bit.ly/2vJdu84
|
||||
serviceWorker.unregister();
|
||||
|
||||
@@ -18,7 +18,7 @@ const isLocalhost = Boolean(
|
||||
)
|
||||
);
|
||||
|
||||
export default function register() {
|
||||
export function register() {
|
||||
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
|
||||
// The URL constructor is available in all browsers that support SW.
|
||||
const publicUrl = new URL(process.env.PUBLIC_URL, window.location);
|
||||
Reference in New Issue
Block a user