From 2ebd7030eb79dff1027551368ecd401fbade49ae Mon Sep 17 00:00:00 2001 From: matthieu42morin Date: Thu, 16 Mar 2023 14:52:11 +0100 Subject: [PATCH] Vite modifications for PWA Changes to be committed: modified: public/manifest.json modified: public/serviceworker.js modified: tsconfig.json renamed: vite.config.js -> vite.config.ts --- public/manifest.json | 5 +++++ public/serviceworker.js | 2 +- tsconfig.json | 2 +- vite.config.js => vite.config.ts | 7 +++++-- 4 files changed, 12 insertions(+), 4 deletions(-) rename vite.config.js => vite.config.ts (87%) diff --git a/public/manifest.json b/public/manifest.json index 101de0b..e80251e 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -6,6 +6,11 @@ "name": "Erant", "orientation": "any", "scope": "/", + "serviceworker": { + "src": "service-worker.js", + "scope": "/", + "use_cache": false + }, "short_name": "erant", "start_url": "/", "theme_color": "#ffffff", diff --git a/public/serviceworker.js b/public/serviceworker.js index 4f43aae..4b2d31b 100644 --- a/public/serviceworker.js +++ b/public/serviceworker.js @@ -1,9 +1,9 @@ // This is the service worker with the combined offline experience (Offline page + Offline copy of pages) +import { workbox } from 'https://storage.googleapis.com/workbox-cdn/releases/5.1.4/workbox-sw.js' const CACHE = 'pwabuilder-offline-page' importScripts('https://storage.googleapis.com/workbox-cdn/releases/5.1.4/workbox-sw.js') - // TODO: replace the following with the correct offline fallback page i.e.: const offlineFallbackPage = "offline.html"; const offlineFallbackPage = '/offline.html' diff --git a/tsconfig.json b/tsconfig.json index 1b5cb37..7f67b92 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,7 @@ "isolatedModules": true, "noEmit": true, "resolveJsonModule": true, - + "allowSyntheticDefaultImports": true, "paths": { "$lib/*": ["./src/lib/*"], "$root/*": ["./*"], diff --git a/vite.config.js b/vite.config.ts similarity index 87% rename from vite.config.js rename to vite.config.ts index 3824645..0994fda 100644 --- a/vite.config.js +++ b/vite.config.ts @@ -4,8 +4,11 @@ import preprocess from 'svelte-preprocess' import path from 'path' // https://vitejs.dev/config/ -export default defineConfig({ +/** @type {import('vite').UserConfig} */ +export default { + // ... resolve: { + alias: { $lib: path.resolve(__dirname, 'src', 'lib'), $root: path.resolve(__dirname), @@ -21,4 +24,4 @@ export default defineConfig({ }) }) ] -}) +}