@aaroon/workbox-rspack-plugin

中文文档
1.0.1发布于 2026/05/23MITTypeScriptESM + CJS构建来源已验证近 30 天下载 27.4万

An Rspack plugin to use workbox

原始使用文档
文档目录7 节
  1. Requirement
  2. Install
  3. Usage
  4. Options
  5. Changelog
  6. Credits
  7. Acknowledgment

workbox-rspack-plugin

NPM version NPM Downloads License Minified Size Build Status

An rspack plugin to use workbox in rspack. Both GenerateSW and InjectManifest are supported. And all the options are the same as the official workbox-webpack-plugin. Currently, it passes all the tests from the official workbox-webpack-plugin, and should be stable for general uses. If you find anything wrong, feel free to open an issue.

Requirement

node >= 18

And one of the following:

@rspack/core@^1.0.0 || ^2.0.0

Or

@rsbuild/core@^1.0.0 || ^2.0.0

Install

npm i -D @aaroon/workbox-rspack-plugin

Or

pnpm i -D @aaroon/workbox-rspack-plugin
yarn add -D @aaroon/workbox-rspack-plugin

Usage

import { GenerateSW, InjectManifest } from '@aaroon/workbox-rspack-plugin'
/**
 * @type import('@rspack/cli').Configuration}
 */
export default {
    plugins: [
        new GenerateSW({
            // options
        }),
        // or
        new InjectManifest({
            // options
        })
    ]
}

If you're using Rsbuild, use it in tools.rspack.plugins:

import { defineConfig } from '@rsbuild/core'
import { GenerateSW, InjectManifest } from '@aaroon/workbox-rspack-plugin'

export default defineConfig({
    tools: {
        rspack: {
            plugins: [
                new GenerateSW({
                    // options
                }),
                // or
                new InjectManifest({
                    // options
                })
            ]
        }
    }
})

Options

Same as workbox-webpack-plugin.

Changelog

Changelog can be found here.

Credits

Most of the code comes from Google's workbox repo, I just make it compatible with Rspack.

Acknowledgment

If you found it useful somehow, I would be grateful if you could leave a star in the project's GitHub repository.

Thank you.

版本与发布记录

@aaroon/workbox-rspack-plugin 共发布 10 个版本,首次发布于 2024/03/10;过去 12 个月发布了 3 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.0.1latest2026/05/235 个月前
1.0.02026/05/155 个月前
0.3.32026/01/199 个月前
0.3.22024/09/012 年前
0.3.12024/04/082 年前
0.3.02024/04/012 年前

关于 @aaroon/workbox-rspack-plugin 的常见问题

@aaroon/workbox-rspack-plugin 是什么?

An Rspack plugin to use workbox

如何安装 @aaroon/workbox-rspack-plugin?

在项目目录运行 npm install @aaroon/workbox-rspack-plugin,或使用 pnpm add / yarn add / bun add。

@aaroon/workbox-rspack-plugin 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@aaroon/workbox-rspack-plugin 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@aaroon/workbox-rspack-plugin 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@aaroon/workbox-rspack-plugin 可以商用吗?

@aaroon/workbox-rspack-plugin 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@aaroon/workbox-rspack-plugin 的下载量有多少?

根据 npm 官方下载统计,@aaroon/workbox-rspack-plugin 在 2026/10/05 – 2026/11/03 这 30 天内被下载 274,156 次,日均约 9,139 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@aaroon/workbox-rspack-plugin 还在维护吗?

最新版本 1.0.1 发布于 2026/05/23(5 个月前);至今共发布 10 个版本,其中过去 12 个月发布了 3 个;首次发布于 2024/03/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。