Registry / web-framework / vite-plugin-serwist

vite-plugin-serwist

JSON →
library10.0.0-preview.14jsnpmunverified

Vite plugin for integrating Serwist (a Workbox-inspired service worker library) into your Vite application. Current stable version is 9.5.7, with 10.0.0-preview.14 available. Supports React, Vue, Svelte, Preact, SolidJS, and TypeScript. Unlike Workbox, Serwist offers modern ESM-first architecture, full TypeScript support, and plugin-specific configurations for various frameworks. Published under the serwistjs GitHub organization with monthly release cadence.

npm install vite-plugin-serwist
INSTALL
IMPORT
SIG · VITE-PLUGIN-SERWIS
V
vite-plugin-serwist
web-frameworkjavascriptv10.0.0-preview.14
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SerwistPlugin
import { SerwistPlugin } from 'vite-plugin-serwist'
const SerwistPlugin = require('vite-plugin-serwist')
ESM-only; Node 20+. Plugin class default export.
SerwistPlugin as serwistPlugin
import serwistPlugin from 'vite-plugin-serwist'
Named export, not default.
type InjectManifestOptions
import type { InjectManifestOptions } from 'vite-plugin-serwist'
import { InjectManifestOptions } from 'vite-plugin-serwist'
Type-only import to avoid runtime inclusion.

Configures SerwistPlugin with inject manifest mode, targeting a service worker source file and output.

import { SerwistPlugin } from 'vite-plugin-serwist'; import { defineConfig } from 'vite'; export default defineConfig({ plugins: [ SerwistPlugin({ swSrc: 'src/sw.ts', swDest: 'dist/sw.js', globDirectory: 'dist', globPatterns: ['**/*.{html,js,css}'], injectionPoint: 'self.__WB_MANIFEST', maximumFileSizeToCacheInBytes: 5 * 1024 * 1024, mode: 'production', }), ], });
Debug
Known issues
breakingvite-plugin-serwist v10 changes the plugin option name from 'swSrc' to 'swSrc' (remains same) but modifies 'injectionPoint' default from 'self.__WB_MANIFEST' to 'self.__SW_MANIFEST'.
fix
Update injectionPoint to 'self.__SW_MANIFEST' or explicitly set to 'self.__WB_MANIFEST'.
affects: >=10.0.0
deprecatedUsing CommonJS require() is deprecated in v9+. The package is ESM-only.
fix
Use import syntax in an ESM project (type: 'module' in package.json or .mjs extension).
affects: >=9.0.0
gotchaThe plugin expects a service worker source file that exports nothing by default; using a non-'self.__WB_MANIFEST' injection point requires updating both the plugin config and the service worker code.
fix
Ensure your service worker source uses the same injection point identifier as the plugin config.
affects: >=9.0.0
gotchaGlob patterns in 'globPatterns' must be relative to 'globDirectory'; common mistake is using absolute paths or patterns that don't match.
fix
Double-check that glob patterns are relative to the output directory (e.g., 'dist').
affects: >=9.0.0
Errors
Common errors & fixes
Cannot find module 'vite-plugin-serwist'
Package not installed; or using older npm versions that don't resolve peer dependencies automatically.
fix
Run 'npm install vite-plugin-serwist' and ensure all peer deps (vite, etc.) are installed.
SerwistPlugin is not a function / SerwistPlugin is not a constructor
Incorrect import: using default import when it's a named export, or using CommonJS require without default.
fix
Use 'import { SerwistPlugin } from 'vite-plugin-serwist'' correctly.
Uncaught ReferenceError: self is not defined
Attempting to use Serwist's service worker code in a non-worker context (e.g., main thread).
fix
Ensure the service worker source file is only imported in a Web Worker or Service Worker environment.
Upgrade
Version history
10.0.0-preview.14latest on npm
Audit
Dependencies
viterequiredPeer dependency for Vite plugin functionality
@serwist/windowoptionalRuntime dependency for type-safe window messaging
Agent activity
34 hits · last 30 days
node
32
Bingbot
1
OpenAI (training)
1
Resources
vite-plugin-serwist — npm install vite-plugin-serwist · libregistry