Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
"lodash": "^4.15.0",
"loop-breaker": "^0.1.0-alpha.7",
"moment": "^2.14.1",
"offline-plugin": "^4.8.1",
"pify": "^2.3.0",
"promise-retry": "^1.1.1",
"prop-types": "^15.5.10",
Expand Down
20 changes: 20 additions & 0 deletions src/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,29 @@ import Immutable from 'immutable';
import installDevTools from 'immutable-devtools';
import Application from './components/Application';
import initI18n from './util/initI18n';
import * as OfflinePluginRuntime from 'offline-plugin/runtime';
import {init as initAnalytics, logPageview} from './clients/googleAnalytics';

installDevTools(Immutable);
OfflinePluginRuntime.install({
onUpdating: () => {
console.log('SW Event:', 'onUpdating');
},
onUpdateReady: () => {
console.log('SW Event:', 'onUpdateReady');
// Tells to new SW to take control immediately
runtime.applyUpdate();
},
onUpdated: () => {
console.log('SW Event:', 'onUpdated');
// Reload the webpage to load into the new version
window.location.reload();
},

onUpdateFailed: () => {
console.log('SW Event:', 'onUpdateFailed');
}
});

initI18n();
initAnalytics();
Expand Down
14 changes: 14 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* eslint-disable import/no-commonjs */
/* eslint-disable comma-dangle */

const OfflinePlugin = require('offline-plugin');
const path = require('path');
const webpack = require('webpack');
const escapeRegExp = require('lodash/escapeRegExp');
Expand Down Expand Up @@ -192,6 +193,19 @@ module.exports = {
WARN_ON_DROPPED_ERRORS: 'false',
GOOGLE_ANALYTICS_TRACKING_ID: 'UA-90316486-2'
}),
// it's always better if OfflinePlugin is the last plugin added https://github.com/NekR/offline-plugin#setup
new OfflinePlugin({
publicPath: '/compiled/',
relativePaths: false,
responseStrategy: 'network-first',
externals: [
'/',
'/compiled/application.css',
],
ServiceWorker: {
navigateFallbackURL: '/',
},
}),
],
resolve: {
alias: {
Expand Down
16 changes: 15 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2187,7 +2187,7 @@ deep-equal@~1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5"

deep-extend@~0.4.0:
deep-extend@^0.4.0, deep-extend@~0.4.0:
version "0.4.2"
resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f"

Expand Down Expand Up @@ -2460,6 +2460,10 @@ ee-first@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"

ejs@^2.3.4:
version "2.5.6"
resolved "https://registry.yarnpkg.com/ejs/-/ejs-2.5.6.tgz#479636bfa3fe3b1debd52087f0acb204b4f19c88"

electron-to-chromium@^1.2.7:
version "1.3.11"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.11.tgz#744761df1d67b492b322ce9aa0aba5393260eb61"
Expand Down Expand Up @@ -5487,6 +5491,16 @@ obuf@^1.0.0, obuf@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/obuf/-/obuf-1.1.1.tgz#104124b6c602c6796881a042541d36db43a5264e"

offline-plugin@^4.8.1:
version "4.8.1"
resolved "https://registry.yarnpkg.com/offline-plugin/-/offline-plugin-4.8.1.tgz#1d73457081185777179c29d9d416f71077a0197a"
dependencies:
deep-extend "^0.4.0"
ejs "^2.3.4"
loader-utils "0.2.x"
minimatch "^3.0.3"
slash "^1.0.0"

on-finished@~2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947"
Expand Down