Skip to content
This repository was archived by the owner on Jan 6, 2019. It is now read-only.

Commit 654b29b

Browse files
author
Didier Franc
committed
Add ServiceWorker → offline-plugin
1 parent a4137e1 commit 654b29b

File tree

6 files changed

+32
-6
lines changed

6 files changed

+32
-6
lines changed

.eslintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
dist/assets/*.js
1+
/dist

assets/favicon.ico

24.3 KB
Binary file not shown.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Get started with ES2015, React and Redux. Including Webpack, ESLint, react-router, fetch ...",
55
"scripts": {
66
"start": "webpack-dev-server --open --config webpack/webpack.config.dev.js",
7-
"build": "rm -rf dist && webpack --config webpack/webpack.config.prod.js",
7+
"build": "rm -rf dist && webpack --config webpack/webpack.config.prod.js && cp -a assets/ dist/",
88
"prod": "cd dist && python -m SimpleHTTPServer 8080",
99
"lint": "eslint src",
1010
"ngrok": "ngrok http -region eu 8080",
@@ -51,6 +51,7 @@
5151
"webpack-dev-server": "2.2.0-rc.0"
5252
},
5353
"dependencies": {
54+
"offline-plugin": "^4.5.3",
5455
"react": "^15.4.1",
5556
"react-dom": "^15.4.1",
5657
"react-redux": "^5.0.1",

src/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Offline from 'offline-plugin/runtime'
12
import React from 'react'
23
import { Provider } from 'react-redux'
34
import { render } from 'react-dom'
@@ -11,6 +12,8 @@ import Login from './components/Login'
1112
import Header from './components/Header'
1213
import { Body } from './components/Styled'
1314

15+
Offline.install()
16+
1417
export const Root = () => (
1518
<Provider store={store}>
1619
<BrowserRouter>

webpack/webpack.config.prod.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const { resolve } = require('path')
22
const webpack = require('webpack')
33
const HtmlWebpackPlugin = require('html-webpack-plugin')
4+
const OfflinePlugin = require('offline-plugin')
45

56
module.exports = {
67
entry: {
@@ -18,8 +19,9 @@ module.exports = {
1819
'react-dom': 'ReactDOM',
1920
},
2021
output: {
21-
path: resolve(__dirname, '../dist/assets'),
2222
filename: '[name].[chunkhash].js',
23+
path: resolve(__dirname, '../dist'),
24+
publicPath: '/',
2325
},
2426
module: {
2527
rules: [
@@ -41,9 +43,15 @@ module.exports = {
4143
names: ['vendor', 'manifest'],
4244
}),
4345
new HtmlWebpackPlugin({
44-
filename: '../index.html',
46+
filename: 'index.html',
4547
title: 'redux-react-starter',
4648
template: 'webpack/template.html',
4749
}),
50+
new OfflinePlugin({
51+
ServiceWorker: {
52+
navigateFallbackURL: '/',
53+
},
54+
AppCache: false,
55+
}),
4856
],
4957
}

yarn.lock

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,7 @@ decamelize@^1.0.0, decamelize@^1.1.1:
14991499
version "1.2.0"
15001500
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
15011501

1502-
deep-extend@~0.4.0:
1502+
deep-extend@^0.4.0, deep-extend@~0.4.0:
15031503
version "0.4.1"
15041504
resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.1.tgz#efe4113d08085f4e6f9687759810f807469e2253"
15051505

@@ -1629,6 +1629,10 @@ [email protected]:
16291629
version "1.1.1"
16301630
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
16311631

1632+
ejs@^2.3.4:
1633+
version "2.5.5"
1634+
resolved "https://registry.yarnpkg.com/ejs/-/ejs-2.5.5.tgz#6ef4e954ea7dcf54f66aad2fe7aa421932d9ed77"
1635+
16321636
elliptic@^6.0.0:
16331637
version "6.3.2"
16341638
resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.3.2.tgz#e4c81e0829cf0a65ab70e998b8232723b5c1bc48"
@@ -3105,7 +3109,7 @@ loader-runner@^2.2.0:
31053109
version "2.2.0"
31063110
resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-2.2.0.tgz#824c1b699c4e7a2b6501b85902d5b862bf45b3fa"
31073111

3108-
loader-utils@^0.2.11, loader-utils@^0.2.16:
3112+
loader-utils@0.2.x, loader-utils@^0.2.11, loader-utils@^0.2.16:
31093113
version "0.2.16"
31103114
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-0.2.16.tgz#f08632066ed8282835dff88dfb52704765adee6d"
31113115
dependencies:
@@ -3530,6 +3534,16 @@ obuf@^1.0.0, obuf@^1.1.0:
35303534
version "1.1.1"
35313535
resolved "https://registry.yarnpkg.com/obuf/-/obuf-1.1.1.tgz#104124b6c602c6796881a042541d36db43a5264e"
35323536

3537+
offline-plugin@^4.5.3:
3538+
version "4.5.3"
3539+
resolved "https://registry.yarnpkg.com/offline-plugin/-/offline-plugin-4.5.3.tgz#39c2bd7a3fc74fadaa601d0aa20dc4f74ae24add"
3540+
dependencies:
3541+
deep-extend "^0.4.0"
3542+
ejs "^2.3.4"
3543+
loader-utils "0.2.x"
3544+
minimatch "^3.0.3"
3545+
slash "^1.0.0"
3546+
35333547
on-finished@~2.3.0:
35343548
version "2.3.0"
35353549
resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947"

0 commit comments

Comments
 (0)