UNPKG

vite-plugin-inject-sw-assets

Version:

A Vite plugin that injects static assets into a custom service worker for use with injectManifest (ideal for Workbox + vite-plugin-pwa setups).

16 lines (15 loc) 707 B
/** * Vite plugin to inject additional static assets into a service worker * for precaching, especially for assets not handled automatically by Workbox. * * This plugin: * - Scans the build output directory (e.g., "dist") for asset files * - Excludes icon files already listed in the PWA manifest (optional) * - Writes a JS file declaring `self.__INJECTED_ASSETS__` for use in the service worker * * @param {InjectSWAssetsOptions} [options={}] - Plugin configuration options * @returns {Plugin} - Vite-compatible plugin object */ import { Plugin } from 'vite'; import type { InjectSWAssetsOptions } from './types'; export default function injectSWAssets(options?: InjectSWAssetsOptions): Plugin;