# hexo-workbox-build

> A hexo plugin to run workbox build. And provide convenient features of PWA and service worker.

Latest version **5.0.0** (published 2026-05-12) · MPL-2.0 license · 0 weekly downloads

## Install

```sh
npm install hexo-workbox-build
pnpm add hexo-workbox-build
yarn add hexo-workbox-build
bun add hexo-workbox-build
```

## Health

**Score 50/100 (C)** — status: active.

Positive: no vulnerabilities; has provenance.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2026-05-12 |
| First published | 2023-07-14 |
| Weekly downloads | 0 |
| License | MPL-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=24 |
| Dependencies | 2 |
| Unpacked size | 37 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| Author | Uiolee (https://github.com/uiolee) |
| Maintainers | uiolee |
| Keywords | hexo, plugin, hexo-plugin, workbox, workbox-build, PWA, offline |

## Links

- npm: https://www.npmjs.com/package/hexo-workbox-build
- Repository: https://github.com/uiolee/hexo-plugin
- Homepage: https://github.com/uiolee/hexo-plugin/tree/main/plugins/hexo-workbox-build
- Issues: https://github.com/uiolee/hexo-plugin/issues
- npm.io page: https://npm.io/package/hexo-workbox-build

## Dependencies (2)

- [nunjucks](https://npm.io/package/nunjucks.md) ^3.2.4
- [workbox-build](https://npm.io/package/workbox-build.md) ^7.0.0

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 5.0.0 (latest) — 2026-05-12
- 4.0.0 — 2026-05-11
- 3.0.1 — 2025-02-18
- 3.0.0 — 2024-10-06
- 2.0.1 — 2024-02-13
- 2.0.0 — 2024-02-10
- 2.0.0-0 — 2024-02-07
- 1.1.1 — 2024-02-03
- 1.1.0 — 2024-01-30
- 1.0.4 — 2023-10-24
- 1.0.3 — 2023-10-16
- 1.0.2 — 2023-07-14
- 1.0.1 — 2023-07-14

## README

# hexo-workbox-build

A hexo plugin to run [workbox-build](https://www.npmjs.com/package/workbox-build) and provide convenient features of PWA and service worker.

## Feature

- run [workbox-build](https://www.npmjs.com/package/workbox-build) via passing through your custom options. ([generateSW mode](https://developer.chrome.com/docs/workbox/modules/workbox-build#generatesw_mode) or [injectManifest mode](https://developer.chrome.com/docs/workbox/modules/workbox-build#injectmanifest_mode))
- generate the script which using to register service-worker.
- reference the register script into html.

This plugin doesn't provide PWA support ready out of the box.

You need to know how to use [workbox-build](https://www.npmjs.com/package/workbox-build), configurate workbox strategy.

## Install

[![NPM Version](https://img.shields.io/npm/v/hexo-workbox-build?logo=npm)](https://www.npmjs.com/package/hexo-workbox-build)
[![node-lts](https://img.shields.io/node/v-lts/hexo-workbox-build?logo=nodedotjs)](https://nodejs.org/about/previous-releases#release-schedule)

```bash
pnpm add hexo-workbox-build

# npm i hexo-workbox-build
```

## Configuration

### Default Configuration

```yml
hexo_workbox_build:
  enable: false

  WB_runWorkboxBuild: true
  WB_swDest: ""
  WB_generateSWOptionsPath: ""
  WB_injectManifestOptionsPath: ""

  REG_generateRegister: true
  REG_registerScriptDest: "registerSW.js"
  # REG_registerScriptNjkPath: "" # default to internal nunjucks template

  REG_injector: true
  REG_injectorNjkString: '<script defer src="{{ REG_registerScriptDest }}"></script>'
```

### Example Configuration

```yml
hexo_workbox_build:
  enable: true

  WB_runWorkboxBuild: true
  WB_swDest: "sw.js"
  WB_generateSWOptionsPath: "workbox/genSWOption.js"
  # WB_injectManifestOptionsPath: "workbox/injMfOption.js"

  REG_generateRegister: true
  # REG_registerScriptDest: 'registerSW.js'
  # REG_registerScriptNjkPath: "" # default to internal nunjucks template

  REG_injector: true
  # REG_injectorNjkString: '<script defer src="{{ REG_registerScriptDest }}"></script>'
```

---

## Options

### enable or disable this plugin

| option name | value type | default value | note                                                                                                                          |
| ----------- | ---------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `enbale`    | boolean    | `false`       | Control whether to enable [`hexo-workbox-build`](https://github.com/uiolee/hexo-plugin/tree/main/plugins/hexo-workbox-build). |

---

### ralated to workbox-build

| option name                    | value type | default value | note                                                                                                                                                                                                                                                                                                                                                       |
| ------------------------------ | ---------- | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `WB_runWorkboxBuild`           | boolean    | `true`        | Control whether to run [`worlbox-build`](https://developer.chrome.com/docs/workbox/modules/workbox-build/).                                                                                                                                                                                                                                                |
| `WB_swDest`                    | string     | ""            | Specify the name and path of `service-worker` that `worlbox-build` generated. (relative to `public` dir). <br><br>**equal to the [`swDest`](https://developer.chrome.com/docs/workbox/modules/workbox-build#properties_10) option in `worlbox-build`.**                                                                                                    |
| `WB_generateSWOptionsPath`     | string     | ""            | Need `WB_swDest` setting.<br>Specify the path of a js file. (relative to your hexo dir), which use default exports the arguments of [`generatesw-mode`](https://developer.chrome.com/docs/workbox/modules/workbox-build/#generatesw-mode) of [`worlbox-build`](https://developer.chrome.com/docs/workbox/modules/workbox-build/).                          |
| `WB_injectManifestOptionsPath` | string     | ""            | Need `WB_swDest` `generatesw-mode` setting.<br>Specify the path of a js file. (relative to your hexo dir), which use default exports the arguments of [`injectmanifest-mode`](https://developer.chrome.com/docs/workbox/modules/workbox-build/#injectmanifest-mode) of [`worlbox-build`](https://developer.chrome.com/docs/workbox/modules/workbox-build/) |

> Note: `injectmanifest-mode` depend on a built `sw.js`.
>
> It means you need to run `generatesw-mode` first in [`hexo-workbox-build`](https://github.com/uiolee/hexo-plugin/tree/main/plugins/hexo-workbox-build).

---

### ralated to register service worker

#### generate the code of registering service-worker

| option name                 | value type | default value   | note                                                                                                                                                         |
| --------------------------- | ---------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `REG_generateRegister`      | boolean    | `true`          | Control whether to generater a javascript, which is use to register `service-worker`.                                                                        |
| `REG_registerScriptDest`    | string     | `registerSW.js` | Need `WB_swDest`.<br>Specify the path of the above javascript code generated. (relative to `public` dir)                                                     |
| `REG_registerScriptNjkPath` | string     | ""              | path of a nunjucks template of the javascript. (relative to your hexo dir)<br>Default template: [`./assets/registerScript.njk`](./assets/registerScript.njk) |

#### insert the registering code into html

| option name             | value type | default value                                                | note                                                                                                                            |
| ----------------------- | ---------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------- |
| `REG_injector`          | boolean    | `true`                                                       | Control whether to Inject the above javascript code into html `<script>`. <br>You can use `REG_injectorNjkString` to custom it. |
| `REG_injectorNjkString` | string     | `<script defer src="{{ REG_registerScriptDest }}"></script>` | Custom the `<scripts>` string.                                                                                                  |

---

---
_Source: https://npm.io/package/hexo-workbox-build · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
