File tree 4 files changed +28
-0
lines changed 4 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ var InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
18
18
var url = require ( 'url' ) ;
19
19
var paths = require ( './paths' ) ;
20
20
var getClientEnvironment = require ( './env' ) ;
21
+ var SWPrecacheWebpackPlugin = require ( 'sw-precache-webpack-plugin' ) ;
21
22
22
23
// @remove -on-eject-begin
23
24
// `path` is not used after eject - see https://github.com/facebookincubator/create-react-app/issues/1174
@@ -273,6 +274,11 @@ module.exports = {
273
274
// having to parse `index.html`.
274
275
new ManifestPlugin ( {
275
276
fileName : 'asset-manifest.json'
277
+ } ) ,
278
+ new SWPrecacheWebpackPlugin ( {
279
+ dontCacheBustUrlsMatching : / \. \w { 8 } \. / ,
280
+ filename : 'service-worker.js' ,
281
+ staticFileGlobsIgnorePatterns : [ / \. m a p $ / , / a s s e t - m a n i f e s t \. j s o n $ / ]
276
282
} )
277
283
] ,
278
284
// Some libraries import Node modules but don't use them in the browser.
Original file line number Diff line number Diff line change 59
59
"recursive-readdir" : " 2.1.0" ,
60
60
"strip-ansi" : " 3.0.1" ,
61
61
"style-loader" : " 0.13.1" ,
62
+ "sw-precache-webpack-plugin" : " ^0.9.0" ,
62
63
"url-loader" : " 0.5.7" ,
63
64
"webpack" : " 2.2.1" ,
64
65
"webpack-dev-server" : " 2.3.0" ,
Original file line number Diff line number Diff line change 3
3
< head >
4
4
< meta charset ="utf-8 ">
5
5
< meta name ="viewport " content ="width=device-width, initial-scale=1 ">
6
+ < link rel ="manifest " href ="%PUBLIC_URL%/manifest.json ">
6
7
< link rel ="shortcut icon " href ="%PUBLIC_URL%/favicon.ico ">
7
8
<!--
8
9
Notice the use of %PUBLIC_URL% in the tag above.
27
28
To begin the development, run `npm start`.
28
29
To create a production bundle, use `npm run build`.
29
30
-->
31
+ < script >
32
+ if ( '%NODE_ENV%' === 'production' && 'serviceWorker' in navigator ) {
33
+ window . addEventListener ( 'load' , function ( ) {
34
+ navigator . serviceWorker . register ( '%PUBLIC_URL%/service-worker.js' ) ;
35
+ } ) ;
36
+ }
37
+ </ script >
30
38
</ body >
31
39
</ html >
Original file line number Diff line number Diff line change
1
+ {
2
+ "short_name" : " React App" ,
3
+ "name" : " React App" ,
4
+ "icons" : [
5
+ {
6
+ "src" : " favicon.ico" ,
7
+ "sizes" : " 192x192" ,
8
+ "type" : " image/png"
9
+ }
10
+ ],
11
+ "start_url" : " ./" ,
12
+ "display" : " standalone"
13
+ }
You can’t perform that action at this time.
0 commit comments