@alwaysmeticulous/recorder-plugin

中文文档
2.346.0发布于 2026/10/06ISCES Module构建来源已验证近 30 天下载 39.5万

Meticulous plugin for Vite, Webpack, Rspack, Rsbuild, and Nuxt that injects the recorder script into the HTML head, plus a Vite plugin that emits CSS source maps for stylesheet coverage.

原始使用文档
文档目录5 节
  1. Installing
  2. Usage
  3. Options
  4. Controlling when the recorder loads
  5. Replacing a manually-added placeholder

@alwaysmeticulous/recorder-plugin

A bundler plugin that injects the Meticulous recorder script into the <head> of your app's HTML, with one entry point per supported bundler/framework.

By default, the recorder is only injected during development builds — matching Meticulous's recommendation to record real sessions in staging or production via an explicit opt-in.

Built on top of unplugin@3 and tsdown. ESM-only. Requires Node.js 20.19+.

Installing

npm install @alwaysmeticulous/recorder-plugin --save-dev
# or with yarn
yarn add -D @alwaysmeticulous/recorder-plugin
# or with pnpm
pnpm add -D @alwaysmeticulous/recorder-plugin

Usage

Vite
// vite.config.ts
import meticulous from "@alwaysmeticulous/recorder-plugin/vite";

export default defineConfig({
  plugins: [
    meticulous({
      recordingToken: "<your-recording-token>",
    }),
  ],
});
Webpack
// webpack.config.mjs
import meticulous from "@alwaysmeticulous/recorder-plugin/webpack";

export default {
  plugins: [meticulous({ recordingToken: "<your-recording-token>" })],
};

The plugin integrates with html-webpack-plugin when present, and otherwise falls back to rewriting any emitted .html assets.

Rspack
// rspack.config.mjs
import meticulous from "@alwaysmeticulous/recorder-plugin/rspack";

export default {
  plugins: [meticulous({ recordingToken: "<your-recording-token>" })],
};
Rsbuild

Prefer the dedicated Rsbuild entry, which hooks into Rsbuild's modifyHTML API:

// rsbuild.config.ts
import { defineConfig } from "@rsbuild/core";
import meticulous from "@alwaysmeticulous/recorder-plugin/rsbuild";

export default defineConfig({
  plugins: [meticulous({ recordingToken: "<your-recording-token>" })],
});

You can also pass the rspack plugin through tools.rspack if you need to compose it with other rspack-only plugins:

// rsbuild.config.ts
import { defineConfig } from "@rsbuild/core";
import meticulous from "@alwaysmeticulous/recorder-plugin/rspack";

export default defineConfig({
  tools: {
    rspack: {
      plugins: [meticulous({ recordingToken: "<your-recording-token>" })],
    },
  },
});
Nuxt
// nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    [
      "@alwaysmeticulous/recorder-plugin/nuxt",
      { recordingToken: "<your-recording-token>" },
    ],
  ],
});

The Nuxt module injects the recorder script via nuxt.options.app.head.script, which feeds into Nitro's render pipeline and works correctly regardless of which bundler Nuxt is using.

Options

import type { Options } from "@alwaysmeticulous/recorder-plugin";
OptionTypeDefaultDescription
recordingTokenstring (required)—Your Meticulous recording token. Emitted as data-recording-token on the injected <script>.
enabled"development" | "always" | "never" | (ctx) => boolean"development"When to inject. "development" only injects during development builds (Vite command === "serve" or webpack/rspack mode !== "production"). Pass a function for full control.
inject"auto" | "replace""auto""auto" prepends a new <script> as the first child of <head>. "replace" swaps a placeholder script tag (see below).
placeholderAttributestring"data-meticulous"Attribute name used to find the placeholder when inject: "replace".
snippetUrlstring"https://snippet.meticulous.ai/v1/meticulous.js"Override the snippet URL.
attributesRecord<string, string | boolean | null | undefined>{}Extra attributes on the <script> tag (e.g. nonce). true emits a boolean attribute; false/null/undefined skip it. Overrides any default attribute, including data-is-production-environment.

The plugin always emits data-is-production-environment="true" or data-is-production-environment="false" on the injected <script> based on the bundler's detected mode (Vite command === "build" && mode === "production", webpack/rspack mode === "production"). Override it via attributes if you need different behaviour:

meticulous({
  recordingToken: "<your-recording-token>",
  attributes: {
    "data-is-production-environment":
      process.env.MY_ENV === "prod" ? "true" : "false",
  },
});

Controlling when the recorder loads

meticulous({
  recordingToken: "<your-recording-token>",
  // Always inject — useful in staging.
  enabled: "always",
});

meticulous({
  recordingToken: "<your-recording-token>",
  // Custom predicate.
  enabled: (ctx) => ctx.framework === "vite" && ctx.mode !== "test",
});

The predicate receives an EnabledContext:

interface EnabledContext {
  framework: "vite" | "webpack" | "rspack";
  mode?: string; // Vite mode / webpack mode / NODE_ENV fallback
  command?: "serve" | "build"; // Vite-only
  isProduction: boolean;
}

Replacing a manually-added placeholder

If you'd rather control where the script lives in your index.html, add a placeholder and switch inject to "replace":

<!-- index.html -->
<head>
  <script data-meticulous></script>
  <!-- ... -->
</head>
meticulous({
  recordingToken: "<your-recording-token>",
  inject: "replace",
  // placeholderAttribute defaults to "data-meticulous"
});

If the placeholder is not found, the plugin falls back to "auto" injection and emits a build warning.

版本与发布记录

@alwaysmeticulous/recorder-plugin 共发布 11 个版本,首次发布于 2026/04/29;过去 12 个月发布了 11 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.346.0latest2026/10/0630 天前
2.338.02026/09/111 个月前
2.337.12026/09/081 个月前
2.337.02026/09/071 个月前
2.333.12026/08/262 个月前
2.293.02026/06/134 个月前

关于 @alwaysmeticulous/recorder-plugin 的常见问题

@alwaysmeticulous/recorder-plugin 是什么?

Meticulous plugin for Vite, Webpack, Rspack, Rsbuild, and Nuxt that injects the recorder script into the HTML head, plus a Vite plugin that emits CSS source maps for stylesheet coverage.

如何安装 @alwaysmeticulous/recorder-plugin?

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

@alwaysmeticulous/recorder-plugin 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/alwaysmeticulous__recorder-plugin 是否存在。

@alwaysmeticulous/recorder-plugin 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@alwaysmeticulous/recorder-plugin 需要什么版本的 Node.js?

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

@alwaysmeticulous/recorder-plugin 可以商用吗?

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

@alwaysmeticulous/recorder-plugin 的下载量有多少?

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

@alwaysmeticulous/recorder-plugin 还在维护吗?

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