diff --git a/examples/assets-generator/vite.config.ts b/examples/assets-generator/vite.config.ts index d1bdab5c..7a363d5c 100644 --- a/examples/assets-generator/vite.config.ts +++ b/examples/assets-generator/vite.config.ts @@ -4,9 +4,31 @@ import { VitePWA } from 'vite-plugin-pwa' const pwaAssets: PWAAssetsOptions = process.env.INLINE_PWA_ASSETS ? { + // disabled: false, + // config: false, + // preset: false, + /* preset: { + transparent: { + sizes: [48, 72, 96, 144, 192, 256, 384, 512], // Comprehensive sizes for various Android devices + favicons: [ + [16, 'favicon-16x16.png'], + [32, 'favicon-32x32.png'], + [48, 'favicon.ico'], + ], + }, + maskable: { + sizes: [192, 512], // Recommended sizes for maskable icons + padding: 0, + }, + apple: { + sizes: [120, 152, 167, 180, 1024], // Covers iPad and iPhone touch icons plus one for the App Store + }, + }, */ image: process.env.PNG ? 'public/source-test.png' : 'public/favicon.svg', + // htmlPreset: '2023', } : { + // disabled: false, config: true, overrideManifestIcons: true, } diff --git a/package.json b/package.json index bb7a135e..ab1fd387 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vite-plugin-pwa", "type": "module", "version": "0.19.7", - "packageManager": "pnpm@8.15.5", + "packageManager": "pnpm@8.15.6", "description": "Zero-config PWA for Vite", "author": "antfu ", "license": "MIT", diff --git a/src/pwa-assets/options.ts b/src/pwa-assets/options.ts index 1aaba88e..7b08d6f4 100644 --- a/src/pwa-assets/options.ts +++ b/src/pwa-assets/options.ts @@ -7,7 +7,8 @@ export function resolvePWAAssetsOptions( return false const { - disabled: useDisabled, + disabled, + preset = 'minimal-2023', image = 'public/favicon.svg', htmlPreset = '2023', overrideManifestIcons = false, @@ -16,21 +17,32 @@ export function resolvePWAAssetsOptions( integration, } = options ?? {} - const configIncluded = 'config' in options && options.config !== undefined && options.config - const presetIncluded = 'preset' in options && options.preset !== undefined && options.preset - const usePreset = !configIncluded && !presetIncluded ? 'minimal-2023' : false - - const disabled = useDisabled || (!configIncluded && !usePreset) - - return { - disabled, - config: disabled || !configIncluded ? false : configIncluded, - preset: disabled || configIncluded ? false : usePreset, + const resolvedConfiguration: ResolvedPWAAssetsOptions = { + disabled: true, + config: false, + preset: false, images: [image], htmlPreset, overrideManifestIcons, includeHtmlHeadLinks, injectThemeColor, integration, - } satisfies ResolvedPWAAssetsOptions + } + + if (disabled === true) + return resolvedConfiguration + + if ('config' in options && !!options.config) { + resolvedConfiguration.disabled = false + resolvedConfiguration.config = options.config + return resolvedConfiguration + } + + if (preset === false) + return resolvedConfiguration + + resolvedConfiguration.disabled = false + resolvedConfiguration.preset = preset + + return resolvedConfiguration }