re-add CDN & fix registerServerWorker
This commit is contained in:
@@ -21,7 +21,7 @@
|
|||||||
"deploy": "gh-pages -d build -m $(TZ=Asia/Shanghai date +\"%y%m%d%H%M%S\")",
|
"deploy": "gh-pages -d build -m $(TZ=Asia/Shanghai date +\"%y%m%d%H%M%S\")",
|
||||||
"eject": "react-scripts eject"
|
"eject": "react-scripts eject"
|
||||||
},
|
},
|
||||||
"homepage": ".",
|
"homepage": "https://://cdn.jsdelivr.net/gh/thuhole/webhole@gh-pages",
|
||||||
"browserslist": {
|
"browserslist": {
|
||||||
"production": [
|
"production": [
|
||||||
">0.2%",
|
">0.2%",
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ const isLocalhost = Boolean(
|
|||||||
export default function register() {
|
export default function register() {
|
||||||
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
|
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
|
||||||
// The URL constructor is available in all browsers that support SW.
|
// The URL constructor is available in all browsers that support SW.
|
||||||
const publicUrl = new URL(process.env.PUBLIC_URL, window.location);
|
// const publicUrl = new URL(process.env.PUBLIC_URL, window.location);
|
||||||
if (publicUrl.origin !== window.location.origin) {
|
// if (publicUrl.origin !== window.location.origin) {
|
||||||
// Our service worker won't work if PUBLIC_URL is on a different origin
|
// // Our service worker won't work if PUBLIC_URL is on a different origin
|
||||||
// from what our page is served on. This might happen if a CDN is used to
|
// // from what our page is served on. This might happen if a CDN is used to
|
||||||
// serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374
|
// // serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
|
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
|
||||||
|
|||||||
Reference in New Issue
Block a user