Skip to content

Commit

Permalink
feat(DEV-13): register serviceworker in production mode
Browse files Browse the repository at this point in the history
  • Loading branch information
hhimanshu committed Jun 22, 2021
1 parent cc878ba commit bd6704d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import '@fontsource/poppins';
import '@fontsource/poppins/900.css';
import AppShell from './components/AppShell';
import { Content } from './components/Content';
import { registerServiceWorker } from './utilities';

// Note: You can enable based on process.env value as well
registerServiceWorker();
if (process.env.NODE_ENV === 'production') {
registerServiceWorker();
}

// This is where your application content can be mounted
const Root = () => <AppShell children={<Content />} />;
Expand Down
2 changes: 1 addition & 1 deletion src/utilities.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const registerServiceWorker = () => {
export const registerServiceWorker = () => {
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker
Expand Down

0 comments on commit bd6704d

Please sign in to comment.