Skip to content

Instantly share code, notes, and snippets.

@dancancro
Created February 28, 2020 01:53
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 dancancro/cb42f5c3ee867bf7daaf0d3052978928 to your computer and use it in GitHub Desktop.
Save dancancro/cb42f5c3ee867bf7daaf0d3052978928 to your computer and use it in GitHub Desktop.
const withOffline = require('next-offline')
module.exports = withOffline({
exportPathMap: function() {
return {
'/': { page: '/' }
};
},
webpack: config => {
config.externals = [
'/'
]
return config
},
target: process.env.NEXT_TARGET || 'serverless',
workboxOpts: {
swDest: 'static/service-worker.js',
runtimeCaching: [
{
urlPattern: /[.](png|jpg|ico|css)/,
handler: 'CacheFirst',
options: {
cacheName: 'assets-cache',
cacheableResponse: {
statuses: [0, 200]
}
}
},
{
urlPattern: /^https:\/\/code\.getmdl\.io.*/,
handler: 'CacheFirst',
options: {
cacheName: 'lib-cache'
}
},
{
urlPattern: /^http.*/,
handler: 'NetworkFirst',
options: {
cacheName: 'http-cache'
}
}
]
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment