Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude subsite urls while using sw precache in angular5

Can I exclude some urls while using sw precache for generating 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 not operator like '!dist/Subscription/**.{js,html,css,png,jpg,gif,svg,eot,ttf,woff,ico}'.But its not working.So that I am getting cannot match any route error while navigating to subsite.After clearing browser data only, I can navigate to subsite. Can anyone pls help me to fix it,pls find my error enter image description here

Thanks

like image 532
kamalav Avatar asked Mar 02 '18 09:03

kamalav


1 Answers

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

like image 132
Stef Chäser Avatar answered Oct 01 '22 10:10

Stef Chäser