From a8842fbb41ce1ac3e43badf4281a71c8297fd7e7 Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Thu, 5 Aug 2021 12:31:02 -0500 Subject: [PATCH] Configure for layer0 deployment --- .gitignore | 2 ++ layer0.config.js | 10 ++++++++++ routes.js | 11 +++++++++++ sw/service-worker.js | 9 +++++++++ 4 files changed, 32 insertions(+) create mode 100644 layer0.config.js create mode 100644 routes.js create mode 100644 sw/service-worker.js 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()