mirror of
https://github.com/jcreek/LivingDexTracker.git
synced 2026-09-14 17:42:17 +00:00
f9b7bbdf0a
Three defects that together meant `npm run test:build` could not pass in any of its four variants: - svelte.config.js constructed adapter-netlify inline and never used the `adapter` export from adapter.mjs, so NODE_ADAPTER=true still produced a flat build/ directory while the build test expects the node adapter's build/client layout. adapter.mjs now returns netlify (the deployment target) or node, and svelte.config.js consumes it. - No route is prerendered, so workbox's glob found no HTML document and a generateSW build precached nothing navigable: the app had no offline support in that mode at all. Adds the root entry and a navigation fallback, matching what prompt-sw.ts already did by hand for injectManifest builds. - The build scripts used by the tests skipped the tailwind step that `build` runs, so static/output.css was never generated on a clean checkout and the app under test had no stylesheet. The offline entry point assertion now also accepts the unquoted object key that prompt-sw.ts's own precache call survives minification as.
88 lines
2.7 KiB
TypeScript
88 lines
2.7 KiB
TypeScript
import { sveltekit } from '@sveltejs/kit/vite';
|
|
import { defineConfig } from 'vite';
|
|
import { SvelteKitPWA } from '@vite-pwa/sveltekit';
|
|
// you don't need to do this if you're using generateSW strategy in your app
|
|
import { generateSW } from './pwa.mjs';
|
|
|
|
export default defineConfig({
|
|
plugins: [
|
|
sveltekit(),
|
|
SvelteKitPWA({
|
|
srcDir: './src',
|
|
mode: 'development',
|
|
// you don't need to do this if you're using generateSW strategy in your app
|
|
strategies: generateSW ? 'generateSW' : 'injectManifest',
|
|
// you don't need to do this if you're using generateSW strategy in your app
|
|
filename: generateSW ? undefined : 'prompt-sw.ts',
|
|
scope: '/',
|
|
base: '/',
|
|
selfDestroying: process.env.SELF_DESTROYING_SW === 'true',
|
|
pwaAssets: {
|
|
config: true
|
|
},
|
|
manifest: {
|
|
name: 'Living Dex Tracker',
|
|
short_name: 'Living Dex Tracker',
|
|
description:
|
|
'A tool to enable you to track your progress in completing the living Pokédex in Pokémon games.',
|
|
icons: [
|
|
{
|
|
src: '/android-chrome-192x192.png',
|
|
sizes: '192x192',
|
|
type: 'image/png'
|
|
},
|
|
{
|
|
src: '/android-chrome-512x512.png',
|
|
sizes: '512x512',
|
|
type: 'image/png',
|
|
purpose: 'any maskable'
|
|
}
|
|
],
|
|
start_url: '/',
|
|
scope: '/',
|
|
display: 'standalone',
|
|
theme_color: '#f00000',
|
|
background_color: '#f0f0f0'
|
|
},
|
|
injectManifest: {
|
|
globPatterns: ['client/**/*.{js,css,ico,png,svg,webp,woff,woff2,webmanifest}'],
|
|
globIgnores: ['**/sprites/**', '**/sprites-small/**']
|
|
},
|
|
workbox: {
|
|
globPatterns: ['client/**/*.{js,css,ico,png,svg,webp,woff,woff2,webmanifest}'],
|
|
globIgnores: ['**/sprites/**', '**/sprites-small/**'],
|
|
// No route is prerendered, so globbing finds no HTML document and a generateSW
|
|
// build would precache nothing navigable - i.e. no offline support at all.
|
|
// prompt-sw.ts does the equivalent with `precache([{ url: '/' }])`.
|
|
additionalManifestEntries: [{ url: '/', revision: null }],
|
|
navigateFallback: '/',
|
|
runtimeCaching: [
|
|
{
|
|
urlPattern: ({ request }) => request.destination === 'image',
|
|
handler: 'CacheFirst',
|
|
options: {
|
|
cacheName: 'image-cache',
|
|
cacheableResponse: { statuses: [0, 200] },
|
|
expiration: {
|
|
maxEntries: 3000,
|
|
maxAgeSeconds: 60 * 60 * 24 * 30,
|
|
purgeOnQuotaError: true
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
devOptions: {
|
|
enabled: false,
|
|
suppressWarnings: process.env.SUPPRESS_WARNING === 'true',
|
|
type: 'module',
|
|
navigateFallback: '/'
|
|
},
|
|
// if you have shared info in svelte config file put in a separate module and use it also here
|
|
kit: {
|
|
includeVersionFile: true
|
|
}
|
|
})
|
|
]
|
|
});
|