Registry / devops / rollup-plugin-workbox-inject

rollup-plugin-workbox-inject

JSON →
library2.0.0jsnpmunverified

Rollup plugin that injects a Workbox precache manifest into a Rollup-compiled service worker. Currently at version 2.0.0 (last updated 2020), this plugin differs from other Rollup/Workbox plugins by letting Rollup control the entire compilation and output of the service worker, instead of Workbox moving the file and bypassing Rollup. It uses workbox-build's getManifest() method and supports all options from that API, plus a customizable injectionPoint (default: 'self.__WB_MANIFEST'). Requires Rollup ^1.2.0 and Workbox v5+ in the service worker. Not actively maintained.

npm install rollup-plugin-workbox-inject
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-WORK
R
rollup-plugin-workbox-inject
devopsjavascriptv2.0.0
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.

default
import workbox from 'rollup-plugin-workbox-inject'
const workbox = require('rollup-plugin-workbox-inject')
ESM default import; CommonJS require works but note that the package is ESM-first.
workbox (require)
const workbox = require('rollup-plugin-workbox-inject');
CommonJS require pattern for use in rollup.config.js (which is often CommonJS).
self.__WB_MANIFEST
self.__WB_MANIFEST
self.__WB_MANIFEST__ or self.wbManifest
The injection point string must match exactly; default is 'self.__WB_MANIFEST'.

Shows how to configure rollup-plugin-workbox-inject in rollup.config.js with @rollup/plugin-replace to set NODE_ENV.

import workbox from 'rollup-plugin-workbox-inject'; import replace from '@rollup/plugin-replace'; export default { input: 'src/sw.js', output: { dir: 'public', format: 'esm', }, plugins: [ replace({ 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production'), }), workbox({ globDirectory: 'public', globPatterns: ['css/**/*.css', 'js/**/*.js'], }), ], };
Debug
Known issues
gotchaRequires Workbox v5+ in your service worker; earlier versions use a different injection pattern.
fix
Use workbox-precaching v5+ and import precacheAndRoute from 'workbox-precaching'.
affects: >=0.0.0
gotchaPlugin uses workbox-build's getManifest() which outputs to console; enable logging by setting NODE_ENV=development.
fix
Add @rollup/plugin-replace and replace 'process.env.NODE_ENV' with your desired value.
affects: >=0.0.0
deprecatedPackage has not been updated since 2020; may not work with Rollup 3+ or latest Workbox.
fix
Consider using @rollup/plugin-workbox or workbox-build directly.
affects: >=0.0.0
breakingRequires Rollup ^1.2.0; not compatible with Rollup 2 or 3.
fix
Upgrade to a maintained plugin or use workbox-build separately.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'rollup-plugin-workbox-inject'
Package not installed or missing from node_modules.
fix
Run: npm install rollup-plugin-workbox-inject --save-dev
TypeError: workbox is not a function
Default import not used correctly (e.g., import { workbox } instead of import workbox).
fix
Use 'import workbox from 'rollup-plugin-workbox-inject'' (default import).
The 'injectionPoint' option is not supported in workbox-build < 5
Using workbox-build v4 with the plugin; the plugin requires workbox-build v5+.
fix
Update workbox-build to v5+ or remove the injectionPoint option.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
rolluprequiredpeer dependency required for plugin to function
Agent activity
4 hits · last 30 days
node
4
Resources
rollup-plugin-workbox-inject — npm install rollup-plugin-workbox-inject · libregistry