diff --git a/common/index.tsx b/common/index.tsx index 17c51cdd..4616d967 100644 --- a/common/index.tsx +++ b/common/index.tsx @@ -5,13 +5,15 @@ import 'sass/styles.scss'; import 'babel-polyfill'; import 'whatwg-fetch'; import React from 'react'; +import OfflineRuntime from 'offline-plugin/runtime'; import { render } from 'react-dom'; import Root from './Root'; import { configuredStore } from './store'; import consoleAdvertisement from './utils/consoleAdvertisement'; -const appEl = document.getElementById('app'); +OfflineRuntime.install(); +const appEl = document.getElementById('app'); render(, appEl); if (module.hot) { diff --git a/package.json b/package.json index 609e4eee..a7614f90 100644 --- a/package.json +++ b/package.json @@ -93,6 +93,7 @@ "node-sass": "4.7.2", "nodemon": "1.14.7", "null-loader": "0.1.1", + "offline-plugin": "4.9.0", "prettier": "1.9.2", "progress": "2.0.0", "react-hot-loader": "3.1.3", diff --git a/webpack_config/webpack.prod.js b/webpack_config/webpack.prod.js index 392e803a..25e33474 100644 --- a/webpack_config/webpack.prod.js +++ b/webpack_config/webpack.prod.js @@ -6,7 +6,7 @@ const webpack = require('webpack'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); const ProgressPlugin = require('webpack/lib/ProgressPlugin'); const BabelMinifyPlugin = require('babel-minify-webpack-plugin'); -// const OfflinePlugin = require('offline-plugin') +const OfflinePlugin = require('offline-plugin'); const base = require('./webpack.base'); const config = require('./config'); const rimraf = require('rimraf'); @@ -66,15 +66,10 @@ base.plugins.push( new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', filename: 'vendor.[chunkhash:8].js' + }), + new OfflinePlugin({ + appShell: '/' }) - // For progressive web apps - // new OfflinePlugin({ - // relativePaths: false, - // AppCache: false, - // ServiceWorker: { - // events: true - // } - // }) ); // minimize webpack output