add offline support via service worker

This commit is contained in:
Kacper Donat 2019-06-26 19:09:28 +02:00
parent b6a529d5af
commit ddadcdd7ca
3 changed files with 9 additions and 5 deletions

View File

@ -14,9 +14,6 @@ framework:
php_errors:
log: true
assets:
version_strategy: 'assets.modified_time_version_strategy'
cache:
# Put the unique name of your app here: the prefix seed
# is used to compute stable namespaces for cache keys.

View File

@ -38,7 +38,7 @@ Vue.use(Vuex);
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.register('/dist/service-worker.js');
navigator.serviceWorker.register('/service-worker.js');
});
}
})();

View File

@ -60,7 +60,14 @@ const config = {
new MiniCssExtractPlugin({ filename: '[name].css' }),
new CopyWebpackPlugin([{ from: './resources/images/', to: '../images/', ignore: ['*.ai'] }]),
new ImageminPlugin({ test: /\.(jpe?g|png|gif|svg)$/i }),
new GenerateSW()
new GenerateSW({
navigationPreload: true,
runtimeCaching: [{
urlPattern: ({event}) => event.request.mode === 'navigate',
handler: 'NetworkFirst',
}],
swDest: '../service-worker.js'
})
],
optimization: {
minimizer: [