From 423444a13942f1d9f18965dbd91e8ec9aed64662 Mon Sep 17 00:00:00 2001 From: youhavetrouble Date: Sun, 24 Sep 2023 23:56:10 +0200 Subject: [PATCH] configure vite plugin for pwa handling --- package.json | 1 + vite.config.ts | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 4f41f92..b2b3aaa 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "npm-run-all": "^4.1.5", "typescript": "~5.1.6", "vite": "4.4.9", + "vite-plugin-pwa": "^0.16.5", "vue-tsc": "^1.8.3" } } diff --git a/vite.config.ts b/vite.config.ts index a3f6d54..ede32a0 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,10 +2,21 @@ import { fileURLToPath, URL } from 'node:url' import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' +import {VitePWA} from "vite-plugin-pwa"; // https://vitejs.dev/config/ export default defineConfig({ - plugins: [vue()], + plugins: [ + vue(), + VitePWA({ + registerType: 'prompt', + injectRegister: 'script', + filename: 'service-worker.js', + workbox: { + globPatterns: ['**/*.{js,css,html,ico,png,jpeg,svg,json}'], + } + }) + ], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url))