Skip to content

Instantly share code, notes, and snippets.

@dYb
Created April 19, 2018 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dYb/eb5a2b6145dd0a9be6ddfe862fcd8539 to your computer and use it in GitHub Desktop.
Save dYb/eb5a2b6145dd0a9be6ddfe862fcd8539 to your computer and use it in GitHub Desktop.
workbox
return workboxBuild.generateSW({
cacheId: 'assassins-workbox',
globDirectory: 'dist',
globPatterns: [
'**/*.{js,css}',
],
globIgnores: [
'**/*-sw.js',
'*.html'
],
// importWorkboxFrom: 'disabled',
// importScripts: [
// 'https://static.ws.126.net/utf8/libs/workbox/v3.1.0/workbox-sw.js'
// ],
ignoreUrlParametersMatching: [/./],
dontCacheBustUrlsMatching: /./,
modifyUrlPrefix: {
'': `https://static.ws.126.net/163/frontend/${projectName}/`
},
clientsClaim: true,
skipWaiting: true,
runtimeCaching: [{
urlPattern: /.*openNewsapp\.js$/,
handler: 'staleWhileRevalidate',
options: {
cacheName: 'open-newsapp',
expiration: {
maxEntries: 3,
},
cacheableResponse: {
statuses: [0, 200]
}
}
}],
swDest: `dist/${type}-sw.js`,
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment