{"id":22293,"library":"rollup-plugin-workbox-inject","title":"rollup-plugin-workbox-inject","description":"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.","status":"maintenance","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/chromeos/static-site-scaffold-modules","tags":["javascript","rollup-plugin","workbox"],"install":[{"cmd":"npm install rollup-plugin-workbox-inject","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-workbox-inject","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-workbox-inject","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for plugin to function","package":"rollup","optional":false}],"imports":[{"note":"ESM default import; CommonJS require works but note that the package is ESM-first.","wrong":"const workbox = require('rollup-plugin-workbox-inject')","symbol":"default","correct":"import workbox from 'rollup-plugin-workbox-inject'"},{"note":"CommonJS require pattern for use in rollup.config.js (which is often CommonJS).","wrong":"","symbol":"workbox (require)","correct":"const workbox = require('rollup-plugin-workbox-inject');"},{"note":"The injection point string must match exactly; default is 'self.__WB_MANIFEST'.","wrong":"self.__WB_MANIFEST__ or self.wbManifest","symbol":"self.__WB_MANIFEST","correct":"self.__WB_MANIFEST"}],"quickstart":{"code":"import workbox from 'rollup-plugin-workbox-inject';\nimport replace from '@rollup/plugin-replace';\n\nexport default {\n  input: 'src/sw.js',\n  output: {\n    dir: 'public',\n    format: 'esm',\n  },\n  plugins: [\n    replace({\n      'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production'),\n    }),\n    workbox({\n      globDirectory: 'public',\n      globPatterns: ['css/**/*.css', 'js/**/*.js'],\n    }),\n  ],\n};","lang":"javascript","description":"Shows how to configure rollup-plugin-workbox-inject in rollup.config.js with @rollup/plugin-replace to set NODE_ENV."},"warnings":[{"fix":"Use workbox-precaching v5+ and import precacheAndRoute from 'workbox-precaching'.","message":"Requires Workbox v5+ in your service worker; earlier versions use a different injection pattern.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Add @rollup/plugin-replace and replace 'process.env.NODE_ENV' with your desired value.","message":"Plugin uses workbox-build's getManifest() which outputs to console; enable logging by setting NODE_ENV=development.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider using @rollup/plugin-workbox or workbox-build directly.","message":"Package has not been updated since 2020; may not work with Rollup 3+ or latest Workbox.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Upgrade to a maintained plugin or use workbox-build separately.","message":"Requires Rollup ^1.2.0; not compatible with Rollup 2 or 3.","severity":"breaking","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run: npm install rollup-plugin-workbox-inject --save-dev","cause":"Package not installed or missing from node_modules.","error":"Error: Cannot find module 'rollup-plugin-workbox-inject'"},{"fix":"Use 'import workbox from 'rollup-plugin-workbox-inject'' (default import).","cause":"Default import not used correctly (e.g., import { workbox } instead of import workbox).","error":"TypeError: workbox is not a function"},{"fix":"Update workbox-build to v5+ or remove the injectionPoint option.","cause":"Using workbox-build v4 with the plugin; the plugin requires workbox-build v5+.","error":"The 'injectionPoint' option is not supported in workbox-build < 5"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}