@@ -2,7 +2,6 @@ const path = require('path');
22const webpack = require ( 'webpack' ) ;
33const fs = require ( 'fs' ) ;
44const HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ;
5- const { GenerateSW } = require ( 'workbox-webpack-plugin' ) ;
65const CopyWebpackPlugin = require ( 'copy-webpack-plugin' ) ;
76const CircularDependencyPlugin = require ( 'circular-dependency-plugin' ) ;
87const includes = [ path . join ( __dirname , 'src' ) , path . join ( __dirname , 'res' ) ] ;
@@ -113,65 +112,4 @@ const config = {
113112 } ,
114113} ;
115114
116- if ( config . mode === 'production' ) {
117- // For an easier debugging with an unminified service worker, add this plugin
118- // in development mode as well.
119- config . plugins . push (
120- new GenerateSW ( {
121- // All navigation that's not in the cache will respond the entry for /index.html. ("SPA" mode)
122- navigateFallback : '/index.html' ,
123- // Cleanup the caches from old workbox installations. This isn't useful
124- // for us _now_ but this can be later for future versions.
125- cleanupOutdatedCaches : true ,
126- // Our biggest asset in production is currently 1.34MB. Therefore 2MB in
127- // production looks sensible (this is the default too).
128- // If it's not cached then index.html is answered instead because of
129- // navigateFallback, then everything it's broken.
130- // In development we want to use a higher limit so that we don't hit the
131- // limit. This isn't normally used but can be used when debugging the
132- // service worker.
133- maximumFileSizeToCacheInBytes :
134- config . mode === 'development' ? 10 * 1024 * 1024 : 2 * 1024 * 1024 ,
135- // All scripts, including imported scripts, will be requested bypassing
136- // HTTP cache, to determine if an update is needed, because we use
137- // `updateViaCache: none` during the register. That's why we don't need to
138- // use a hash or version in this file name.
139- // For more information and background, see:
140- // - discussion in https://github.com/w3c/ServiceWorker/issues/106
141- // - chrome update in https://developer.chrome.com/blog/fresher-sw/
142- // - step 8.21 in https://w3c.github.io/ServiceWorker/#update-algorithm
143- importScripts : [ '/service-worker-compat.js' ] ,
144- navigateFallbackDenylist : [
145- // requests to docs and photon example pages shouldn't be redirected to
146- // the index file as they're not part of the SPA
147- / ^ \/ d o c s (?: \/ | $ ) / ,
148- / ^ \/ p h o t o n (?: \/ | $ ) / ,
149- // Allow navigating to source maps. This is not necessary, but it is
150- // more developer friendly.
151- / ^ \/ [ ^ / ? ] + \. m a p $ / ,
152- // While excluding the service worker file isn't necessary to work, it's
153- // convenient that we can just access it from a browser.
154- / ^ \/ s w \. j s / ,
155- ] ,
156- exclude : [
157- // exclude user docs and photon from the cache
158- 'docs' ,
159- 'photon' ,
160- // exclude also the netlify-specific files that aren't actually served
161- // because this would fail the service worker installation
162- '_headers' ,
163- '_redirects' ,
164- // do not cache source maps
165- / \. m a p $ / ,
166- // nor the service worker imported script
167- 'service-worker-compat.js' ,
168- ] ,
169- // This is the service worker file name. It should never change if we want
170- // that the browser updates it. If this changes it will never be updated
171- // and the user will be stuck with an old version.
172- swDest : 'sw.js' ,
173- } )
174- ) ;
175- }
176-
177115module . exports = config ;
0 commit comments