Exclude child node references when using sw precache in angular5

Can I exclude some URLs when using sw precache to create a service worker. Below is my swprecache.config.json

module.exports = { navigateFallback: '/index.html', stripPrefix: 'dist', root: 'dist/', staticFileGlobs: [ 'dist/index.html', 'dist/**.js', 'dist/**.css', 'dist/**.ico', 'dist/assets/images/**.jpg', 'dist/assets/images/**.png', 'dist/assets/images/**.gif', 'dist/assets/js/**/**.js', 'dist/assets/js/**.js', 'dist/assets/css/**.css', 'dist/assets/fonts/**.{js,html,css,png,jpg,gif,svg,eot,ttf,woff,ico}', 'dist/**.{js,html,css,png,jpg,gif,svg,eot,ttf,woff,ico}', '!dist/Subscription/**.{js,html,css,png,jpg,gif,svg,eot,ttf,woff,ico}' ], runtimeCaching: [{ urlPattern: /^https:\/\/netdna\.bootstrapcdn\.com\//, handler: 'networkFirst' }] 

};

I tried to use a different operator than '! dist / Subscription / **. {js, html, css, png, jpg, gif, svg, eot, ttf, woff, ico} '. But its not working. what I get cannot compare with any route error when navigating a subsite. After clearing only the browser data, I can go to the child node. Can someone help me fix this, pls find my mistake enter image description here

thanks

+8
angular service-worker angular5 sw-precache
source share
1 answer

this should work:

 staticFileGlobs: [ 'dist/index.html', 'dist/*.{js,css,ico}', 'dist/!(Subscription)/**/*.{js,html,css,png,jpg,gif,svg,eot,ttf,woff,ico}' ] 

found here: https://github.com/GoogleChromeLabs/sw-precache/issues/97

+1
source share

All Articles