diff --git a/.gitignore b/.gitignore index a715943..522afff 100644 --- a/.gitignore +++ b/.gitignore @@ -89,3 +89,5 @@ dist .DS_Store /static/tailwind.css /.vscode/snipsnap.code-snippets +# Layer0 generated build directory +.layer0 diff --git a/layer0.config.js b/layer0.config.js new file mode 100644 index 0000000..b59548b --- /dev/null +++ b/layer0.config.js @@ -0,0 +1,10 @@ +'use strict' + +// This file was automatically added by layer0 deploy. +// You should commit this file to source control. + +module.exports = { + backends: {}, + includeNodeModules: true, + connector: '@layer0/nuxt', +} diff --git a/routes.js b/routes.js new file mode 100644 index 0000000..d440c2f --- /dev/null +++ b/routes.js @@ -0,0 +1,11 @@ +// This file was added by layer0 init. +// You should commit this file to source control. + +const { Router } = require('@layer0/core/router') +const { nuxtRoutes } = require('@layer0/nuxt') + +module.exports = new Router() + .match('/service-worker.js', ({ serviceWorker }) => { + serviceWorker('.nuxt/dist/client/service-worker.js') + }) + .use(nuxtRoutes) diff --git a/sw/service-worker.js b/sw/service-worker.js new file mode 100644 index 0000000..c6ab069 --- /dev/null +++ b/sw/service-worker.js @@ -0,0 +1,9 @@ +import { skipWaiting, clientsClaim } from 'workbox-core' +import { precacheAndRoute } from 'workbox-precaching' +import { Prefetcher } from '@layer0/prefetch/sw' + +skipWaiting() +clientsClaim() +precacheAndRoute(self.__WB_MANIFEST || []) + +new Prefetcher().route()