我正在尝试将workbox-webpack-plugin配置为显示脱机页面,而不使用JavaScript navigator.onLine
中的API重新加载所有页面
这是我在webpack.config.js
上的配置:
const { GenerateSW } = require('workbox-webpack-plugin')
module.exports = {
//...
plugins: [
new GenerateSW({
//...
runtimeCaching: [{
urlPattern: ({ event }) => event.request.mode === 'navigate',
handler: ({ url }) => fetch(url.href).catch(() => !navigator.onLine && caches.match('/offline.html'))
}]
})
]
}
不工作:(