[Glitch] Replace to `workbox-webpack-plugin` from `offline-plugin`
Port 81e1cc5fec
to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
6c7bb926d8
commit
54ae7a221e
|
@ -1,9 +1,9 @@
|
||||||
import * as registerPushNotifications from 'flavours/glitch/actions/push_notifications';
|
|
||||||
import { setupBrowserNotifications } from 'flavours/glitch/actions/notifications';
|
|
||||||
import { default as Mastodon, store } from 'flavours/glitch/containers/mastodon';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import ready from './ready';
|
import * as registerPushNotifications from 'flavours/glitch/actions/push_notifications';
|
||||||
|
import { setupBrowserNotifications } from 'flavours/glitch/actions/notifications';
|
||||||
|
import Mastodon, { store } from 'flavours/glitch/containers/mastodon';
|
||||||
|
import ready from 'flavours/glitch/util/ready';
|
||||||
|
|
||||||
const perf = require('./performance');
|
const perf = require('./performance');
|
||||||
|
|
||||||
|
@ -24,10 +24,20 @@ function main() {
|
||||||
|
|
||||||
ReactDOM.render(<Mastodon {...props} />, mountNode);
|
ReactDOM.render(<Mastodon {...props} />, mountNode);
|
||||||
store.dispatch(setupBrowserNotifications());
|
store.dispatch(setupBrowserNotifications());
|
||||||
if (process.env.NODE_ENV === 'production') {
|
|
||||||
// avoid offline in dev mode because it's harder to debug
|
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
|
||||||
require('offline-plugin/runtime').install();
|
import('workbox-window')
|
||||||
|
.then(({ Workbox }) => {
|
||||||
|
const wb = new Workbox('/sw.js');
|
||||||
|
|
||||||
|
return wb.register();
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
store.dispatch(registerPushNotifications.register());
|
store.dispatch(registerPushNotifications.register());
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
perf.stop('main()');
|
perf.stop('main()');
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue