Add a serviceworker (#234)

* Add a serviceworker

* rename + fix random extra character

* Fixing worker typings

* Fixing types properly this time.

* Once of those rare cases where this matters.

* Naming the things.

* Move registration to the app (so we can use snackbar later)

* Moving SW plugin later so it picks up things like HTML

* MVP service worker

* Two stage-service worker

* Fix prerendering by conditionally awaiting Custom Elements polyfill.

* Fix icon 404's

* add doc comment to autoswplugin

* Fix type
This commit is contained in:
Jason Miller
2018-11-08 07:02:05 -05:00
committed by Jake Archibald
parent e4e130c5d6
commit 7d42d4f973
28 changed files with 450 additions and 36 deletions

View File

@@ -36,12 +36,17 @@ export default class App extends Component<Props, State> {
constructor() {
super();
import('../compress').then((module) => {
import(
/* webpackChunkName: "main-app" */
'../compress',
).then((module) => {
this.setState({ Compress: module.default });
}).catch(() => {
this.showSnack('Failed to load app');
});
navigator.serviceWorker.register('../../sw');
// In development, persist application state across hot reloads:
if (process.env.NODE_ENV === 'development') {
this.setState(window.STATE);