Skip to content

VitePWAOptions ​

Interface unplugin-pwa-core

Plugin options.

Properties ​

PropertyTypeDefaultDescription
additionalManifestEntries?string | ManifestEntry[]A list of entries to be precached, in addition to any entries that are generated as part of the build configuration.
additionalManifestEntriesGenerator?() => AsyncGenerator<string | ManifestEntry, undefined, void>Async generator that yields additional entries to be preached.
base?string"base" options from Vite or the corresponding bundler or framework integration.The base for your app.
buildBase?stringvite.base.When Vite's build folder is not the same as your base root folder, configure it here.

This option will be useful for integrations like vite-plugin-laravel where Vite's build folder is public/build but Laravel's base path is public.

This option will be used to configure the path for the service worker, registerSW.js and the web manifest assets.

For example, if your base path is /, then, in your Laravel PWA configuration use buildPath: '/build/'.
buildSWPartial<Omit<BuildServiceWorkerOptions<T>, "minify" | "maximumFileSizeToCacheInBytes" | "throwMaximumFileSizeToCacheInBytes" | "additionalManifestEntries" | "additionalManifestEntriesGenerator" | "swType" | "swDest" | "swSrc">> & Pick<InjectManifestOptions, "swSrc"> | Partial<Omit<LegacyBuildServiceWorkerOptions<T>, "minify" | "maximumFileSizeToCacheInBytes" | "throwMaximumFileSizeToCacheInBytes" | "additionalManifestEntries" | "additionalManifestEntriesGenerator" | "swType" | "swDest" | "swSrc">> & Pick<InjectManifestOptions, "swSrc"> | Partial<Omit<BuildServiceWorkerOptions<T>, "minify" | "maximumFileSizeToCacheInBytes" | "throwMaximumFileSizeToCacheInBytes" | "additionalManifestEntries" | "additionalManifestEntriesGenerator" | "swType" | "swDest" | "swSrc">> & Pick<InjectManifestOptions, "swSrc">The workbox object for buildSW strategy
cwd?stringprocess.cwd()Current working directory to load external configuration options.
devOptions?DevOptionsDevelopment options.
disablebooleanfalseDisable service worker registration and generation on build?
filename?string'sw.js'
generateSWPartial<Omit<BuildGenerateSWOptions<T>, "swType" | "swDest" | "minify" | "maximumFileSizeToCacheInBytes" | "throwMaximumFileSizeToCacheInBytes" | "additionalManifestEntries" | "additionalManifestEntriesGenerator">>The workbox object for generateSW strategy
includeAssetsstring | string[] | undefinedpublic resources to be added to the PWA manifest.

You don't need to add manifest icons here, it will be auto included.

The public directory will be resolved from Vite's publicDir option directory.
includeManifestbooleantrueBy default, the manifest will be included on the service worker *precache* manifest.
includeManifestIconsbooleantrueBy default, the icons listed on manifest option will be included on the service worker *precache* if present under Vite's publicDir option directory.
includeManifestScreenshotsbooleanfalseBy default, the screenshots listed on manifest option won't be included on the service worker *precache* if present under Vite's publicDir option directory.
includeManifestShortcutIconsbooleantrueBy default, the shortcut icons listed on manifest option will be included on the service worker *precache* if present under Vite's publicDir option directory.
injectManifestPartial<Omit<BuildSWOptions<T>, "swType" | "swDest" | "minify" | "maximumFileSizeToCacheInBytes" | "throwMaximumFileSizeToCacheInBytes" | "additionalManifestEntries" | "additionalManifestEntriesGenerator">>The workbox object for injectManifest strategy
injectRegisterfalse | "inline" | "script" | "script-defer" | "auto" | null'auto'Inject the service worker register inlined in the index.html

With auto set, depends on whether you used the import { registerSW } from 'virtual:pwa-register' it will do nothing or use the script mode

inline - inject a simple register, inlined with the generated html

script - inject <script/> in <head> with src attribute to a generated script to register the service worker

script-defer - inject <script defer /> in <head>, with src attribute to a generated script to register the service worker

null - deprecated, use false instead

false - do nothing, you will need to register the sw you self, or imports from virtual:pwa-register
manifestfalse | Partial<ManifestOptions>The manifest object
manifestFilename?string'manifest.webmanifest'
maximumFileSizeToCacheInBytes?number2097152This value can be used to determine the maximum size of files that will be precached. This prevents you from inadvertently precaching very large files that might have accidentally matched one of your patterns.
mergeOptions?booleanfalseWhen path is specified, should merge inlined options and the configuration?

NOTE: inlined options will override external configuration options.
minify?booleanShould minify the output?
- when specified it is preserved
- true when sourcemap is not set to false or mode is set to production
- otherwise false
outDir?string'dist'
path?stringpath to load external configuration options:
- can be an absolute path
- can be a relative path, which will be resolved relative to cwd (or process.cwd() if cwd is not specified)
pwaAssets?PWAAssetsOptionsPWA assets generation and injection.
registerType?"prompt" | "autoUpdate"'prompt'Mode for the virtual register. Is NOT available for strategy injectRegister, only use for strategy generateSW

prompt - you will need to show a popup/dialog to the user to confirm the reload.

autoUpdate - when new content is available, the new service worker will update caches and reload all browser windows/tabs with the application open automatically, it must take the control for the application to work properly.
scope?stringsame as base of Vite's configThe scope to register the Service Worker
selfDestroying?SelfDestroyingOptionsThe workbox object for selfDestroying strategy.
strategies?S'generateSW'
swType?TService worker type.
throwMaximumFileSizeToCacheInBytes?booleantrueShould maximumFileSizeToCacheInBytes exceeded throw an error?.
updateViaCache?ServiceWorkerUpdateViaCacheThe update via cache
useCredentials?booleanfalseWhether to add the crossorigin="use-credentials" attribute to <link rel="manifest">
workboxPartial<Omit<BuildGenerateSWOptions<T>, "swType" | "swDest" | "minify" | "maximumFileSizeToCacheInBytes" | "throwMaximumFileSizeToCacheInBytes" | "additionalManifestEntries" | "additionalManifestEntriesGenerator">>The workbox object for generateSW

Released under the MIT License.