{"id":18764485,"url":"https://github.com/modernweb-dev/rollup-plugin-workbox","last_synced_at":"2025-07-11T02:35:26.581Z","repository":{"id":216704475,"uuid":"742093294","full_name":"modernweb-dev/rollup-plugin-workbox","owner":"modernweb-dev","description":"Rollup plugin that builds a service worker with workbox as part of your rollup build","archived":false,"fork":false,"pushed_at":"2024-04-04T22:08:05.000Z","size":349,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-07-02T19:25:31.337Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/modernweb-dev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"modernweb-dev","open_collective":"modern-web"}},"created_at":"2024-01-11T18:43:52.000Z","updated_at":"2024-05-17T16:55:41.000Z","dependencies_parsed_at":"2024-04-16T07:20:55.237Z","dependency_job_id":"6fd5425a-eb43-4d6d-a872-472eaeee96b6","html_url":"https://github.com/modernweb-dev/rollup-plugin-workbox","commit_stats":{"total_commits":2,"total_committers":2,"mean_commits":1.0,"dds":0.5,"last_synced_commit":"74232a51c936d00deb8677fa8213f1b18dce885c"},"previous_names":["modernweb-dev/rollup-plugin-workbox"],"tags_count":0,"template":false,"template_full_name":"modernweb-dev/package-template","purl":"pkg:github/modernweb-dev/rollup-plugin-workbox","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modernweb-dev%2Frollup-plugin-workbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modernweb-dev%2Frollup-plugin-workbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modernweb-dev%2Frollup-plugin-workbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modernweb-dev%2Frollup-plugin-workbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/modernweb-dev","download_url":"https://codeload.github.com/modernweb-dev/rollup-plugin-workbox/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modernweb-dev%2Frollup-plugin-workbox/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264025884,"owners_count":23545769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T18:30:01.778Z","updated_at":"2025-07-11T02:35:26.563Z","avatar_url":"https://github.com/modernweb-dev.png","language":"TypeScript","readme":"# rollup-plugin-workbox\n\n[![Published on npm](https://img.shields.io/npm/v/rollup-plugin-workbox.svg)](https://www.npmjs.com/package/rollup-plugin-workbox)\n\nRollup plugin that builds a service worker with workbox as part of your rollup build\n\n## Usage\n\nThis package provides two rollup plugins: one that generates a complete service worker for you and one that generates a list of assets to precache that is injected into a service worker file.\n\nThe plugins are implemented as two function in the rollup-plugin-workbox module, named `generateSW` and `injectManifest`.\n\n### `generateSW`\n\nImport the `generateSW` plugin from `rollup-plugin-workbox`, and add it to your `plugins` array in your `rollup.config.js`. The plugin takes a workbox config object, and an optional render function as the second argument.\n\nYou can find a detailed list of supported properties for the workbox config object [here](https://developers.google.com/web/tools/workbox/modules/workbox-build#generatesw_mode).\n\n```js\nconst { generateSW } = require('rollup-plugin-workbox');\n\nmodule.exports = {\n  input: 'main.js',\n  output: {\n    file: 'dist/bundle.js',\n    format: 'esm',\n  },\n  plugins: [\n    generateSW({\n      swDest: '/dist/sw.js',\n      globDirectory: 'demo/dist/',\n    }),\n  ],\n};\n```\n\nYou can also `require` your `workbox-config.js` file and pass it to the plugin.\n\n```js\nconst { generateSW } = require('rollup-plugin-workbox');\n\nconst workboxConfig = require('./workbox-config.js');\n\nmodule.exports = {\n  // ...\n  plugins: [generateSW(workboxConfig)],\n};\n```\n\nYou can also customize the console output after workbox has generated your service worker by passing an optional render function as the second argument to the plugin:\n\n```js\nconst { generateSW } = require('rollup-plugin-workbox');\n\nconst workboxConfig = require('./workbox-config.js');\n\nmodule.exports = {\n  // ...\n  plugins: [\n    generateSW(workboxConfig, {\n      render: ({ swDest, count, size }) =\u003e {\n        console.log('📦', swDest, '#️⃣', count, '🐘', size);\n      },\n    }),\n  ],\n};\n```\n\n### `injectManifest`\n\nImport the `injectManifest` plugin from `rollup-plugin-workbox`, and add it to your `plugins` array in your `rollup.config.js`. The plugin takes a workbox config object, and an optional render function as the second argument.\n\nYou can find a detailed list of supported properties for the workbox config object [here](https://developers.google.com/web/tools/workbox/modules/workbox-build#injectmanifest_mode).\n\n```js\nconst { injectManifest } = require('rollup-plugin-workbox');\n\nmodule.exports = {\n  input: 'main.js',\n  output: {\n    file: 'dist/bundle.js',\n    format: 'esm',\n  },\n  plugins: [\n    injectManifest({\n      swSrc: 'sw.js',\n      swDest: '/dist/sw.js',\n      globDirectory: 'demo/dist/',\n    }),\n  ],\n};\n```\n\nYou can also `require` your `workbox-config.js` file and pass it to the plugin.\n\n```js\nconst { injectManifest } = require('rollup-plugin-workbox');\n\nconst workboxConfig = require('./workbox-config.js');\n\nmodule.exports = {\n  // ...\n  plugins: [injectManifest(workboxConfig)],\n};\n```\n\nYou can also customize the console output after workbox has created your service worker by passing an optional render function as the second argument to the plugin:\n\n```js\nconst { injectManifest } = require('rollup-plugin-workbox');\n\nconst workboxConfig = require('./workbox-config.js');\n\nmodule.exports = {\n  // ...\n  plugins: [\n    injectManifest(workboxConfig, {\n      render: ({ swDest, count, size }) =\u003e {\n        console.log('📦', swDest, '#️⃣', count, '🐘', size);\n      },\n    }),\n  ],\n};\n```\n\n### Bundling\n\nWhen using `injectManifest`, your service worker will also automatically get bundled via `esbuild`. During bundling, any mentions of Workbox's internal usage of `process.env` variables will also be replaced, so you'll end up with a service worker that will have browser-compatible syntax only.\n\nYou can override the `esbuild` options used like so:\n\n```js\nconst { injectManifest } = require('rollup-plugin-workbox');\n\nconst workboxConfig = require('./workbox-config.js');\n\nmodule.exports = {\n  // ...\n  plugins: [\n    injectManifest(workboxConfig, {\n      esbuild: {\n        minify: false,\n      },\n    }),\n  ],\n};\n```\n","funding_links":["https://github.com/sponsors/modernweb-dev","https://opencollective.com/modern-web"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodernweb-dev%2Frollup-plugin-workbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmodernweb-dev%2Frollup-plugin-workbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodernweb-dev%2Frollup-plugin-workbox/lists"}