Skip to content

Commit

Permalink
fix(pwa): vite-pwa not offline compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammed-Rahif committed Oct 4, 2024
1 parent 2111f84 commit f860d07
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ import { defineConfig } from 'vite';
import { svelte } from '@sveltejs/vite-plugin-svelte';
import path from 'path';

function baseUrl() {
const baseArgIndex = process.argv.indexOf('--base');
if (baseArgIndex !== -1 && baseArgIndex + 1 < process.argv.length) {
return process.argv[baseArgIndex + 1];
}
return null;
}

// https://vitejs.dev/config/
export default defineConfig({
resolve: {
Expand All @@ -11,7 +19,7 @@ export default defineConfig({
'@': path.resolve('./src/lib')
}
},
base: '/Notpad',
base: '/Notpad/',
build: {
outDir: 'www'
},
Expand All @@ -22,14 +30,13 @@ export default defineConfig({
plugins: [
svelte(),
VitePWA({
registerType: 'prompt',
injectRegister: false,

registerType: 'autoUpdate',
injectRegister: 'auto',
base: baseUrl() ?? '/Notpad/',
pwaAssets: {
disabled: false,
config: true
},

manifest: {
name: 'Notpad',
short_name: 'Notpad',
Expand Down Expand Up @@ -57,13 +64,11 @@ export default defineConfig({
start_url: '/Notpad',
scope: '.'
},

workbox: {
globPatterns: ['**/*.{js,css,html,svg,png,ico}'],
cleanupOutdatedCaches: true,
clientsClaim: true
},

devOptions: {
enabled: false,
navigateFallback: 'index.html',
Expand Down

0 comments on commit f860d07

Please sign in to comment.