@clickmax/rsbuild-plugin

中文文档
1.0.0发布于 2026/11/06GPL-3.0-onlyTypeScriptES Module近 30 天下载 4902

Clickmax platform integration for Rsbuild: React, Tailwind CSS and TanStack Start with static prerendering, packaged into a publishable site artifact.

原始使用文档
文档目录11 节
  1. How a site is structured
  2. What rsbuild build guarantees
  3. Make controls discoverable
  4. Navigation between published pages
  5. Options
  6. What you can and cannot override in rsbuild.config.ts
  7. Environment
  8. Retrying an upload without rebuilding
  9. Errors
  10. Supported toolchain
  11. License

@clickmax/rsbuild-plugin

The build setup for websites made on Clickmax. One plugin configures Rsbuild with React 19, Tailwind CSS 4 and TanStack Start, renders every page to static HTML at build time, and packages the result so Clickmax can publish it.

You do not need to configure React, Tailwind, routing or output paths yourself. The whole configuration of a Clickmax site is:

// rsbuild.config.ts
import { defineConfig } from '@rsbuild/core'
import { clickmax } from '@clickmax/rsbuild-plugin'

export default defineConfig({ plugins: [clickmax()] })
rsbuild dev     # local development with hot reload
rsbuild build   # production build: dist/client, dist/server and the publishable dist/clickmax/

The matching TypeScript settings ship with the package; a site's tsconfig.json only needs its own include list and import aliases:

{
  "extends": "@clickmax/rsbuild-plugin/tsconfig",
  "include": ["**/*.ts", "**/*.tsx"],
  "compilerOptions": { "paths": { "#/*": ["./src/*"] } }
}

How a site is structured

PathPurpose
src/routes/File-based routes. index.tsx is /, about/team.tsx is /about/team, _layout.tsx wraps children without adding a URL segment, posts/$slug.tsx is a dynamic route.
src/routes/__root.tsxThe HTML document shell (<html>, <head>, <body>).
src/styles.cssGlobal stylesheet, imported with ?url from the root route. Tailwind utilities are available everywhere under src/.
public/Files copied verbatim to the site root: images, fonts, robots.txt, downloadable documents. Reference them with absolute paths such as /images/logo.png (prefixed with basePath when the site is not mounted at /).
src/assets/ (or anywhere under src/)Images and other files imported from code. They get a content hash in their name and are cached forever.

New routes are picked up automatically; run rsbuild build (or keep rsbuild dev running) to regenerate the route tree.

What rsbuild build guarantees

The site is published as static files; there is no server at runtime. The build enforces that:

  • Every route that has a component and no path parameter is rendered to <route>/index.html. Dynamic routes ($slug) are rendered only for the paths you list in prerender.paths.
  • Links between pages (<a href>) are followed and the linked pages are rendered too. Links to other websites and to files in public/ are left alone.
  • Every image, stylesheet, script, font or document a page references by a same-site URL exists in the output. A missing file fails the build with the page and the URL that referenced it.
  • A route that fails to render (for example a loader that throws) fails the build. Nothing is published partially.
  • Data can be fetched inside a route loader with fetch from a public API. Loaders run at build time to render the page and again in the browser on client-side navigation, so they must not use Node-only APIs such as fs. Server functions (createServerFn) and server route handlers are not supported: there is no server once the site is live. Client code that uses server functions, and pages that link to API routes, fail the build with the file or URL involved.
  • No server code is published. dist/server/ exists only to render pages during the build.

The published output is listed in dist/clickmax/manifest.json (routes, files, sizes and hashes). dist/clickmax/site.tar.gz is the archive Clickmax receives.

Make controls discoverable

The funnel lists what each published route renders, read from the route's final HTML into dist/clickmax/manifest.json. Only elements marked by Clickmax runtime components count: each one writes data-cx-component and data-cx-entity-id on its root element, and the build records the element under its DOM ID. A custom trigger is declared with CxTrigger from @clickmax/rsbuild-plugin/runtime/core:

import { CxTrigger, useCxTrigger } from '@clickmax/rsbuild-plugin/runtime/core'

<CxTrigger id="read-70" label="Read 70% of the page" />

// In the site's own code, when the condition is met:
const fire = useCxTrigger('read-70')
fire()

Events leave the browser only through ClickmaxProvider, rendered once in the root route around <Outlet /> (the Clickmax site template already does this). Without it, CxTrigger is listed in the manifest but never fires.

data-cx-componentListed as
buttonButton click
linkLink click
visibleElement visibility
lead-form, formForm submission and contact capture
trigger (CxTrigger)Custom trigger, named by its label

Rules the build enforces, failing with the route and the element when broken:

  • Every marked element has an id of 1-255 characters without whitespace, control characters or commas, unique across the rendered document. The same ID may be reused on different routes. Pass IDs explicitly; never generate them with useId(), which changes between builds.
  • A CxTrigger label has at most 255 characters and no line breaks. The funnel shows it as-is.
  • One element carries either a runtime marker or a Browser SDK annotation, never both.
  • Unknown data-cx-component values fail; do not write the attribute by hand.

Render marked elements during prerender: client-only modals and computed elements are not in the HTML the build reads. Use aria-label or title for a useful label; otherwise the build uses the visible text, a name, an input value or the ID. Checkout embeds and Vturb players are recorded as integration discoveries, which do not prove purchase or video-event support.

Browser SDK annotations (data-cx-track, form[data-cx-ingest-form], cm-* classes) keep working in the browser but are not listed for the funnel. The build prints capability warning legacy_selector with the route and IDs of each one it finds.

Navigation between published pages

Use normal TanStack Link, Navigate, useNavigate() and router.navigate() calls, or native anchors. The site owns its destinations. Funnel arrows represent the funnel manually and never rewrite button, link, form or checkout navigation.

The plugin automatically observes the router returned by your existing getRouter factory when the published Browser SDK is active. No tracking helper, action wrapper or router registration is required in application source. Hydrated client navigation and prerendered direct entry both work; do not force document reloads for tracking.

Options

All options are optional. The defaults match the Clickmax site template.

clickmax({
  srcDirectory: 'src',            // where the application code lives
  basePath: '/',                  // mount path of the site, e.g. '/landing' for a sub-path deployment
  prerender: {
    paths: ['/posts/hello'],      // concrete paths to render for dynamic routes such as /posts/$slug
    crawlLinks: true,             // follow same-site links in rendered pages
    concurrency: 4,               // pages rendered in parallel
  },
  plugins: [],                    // extra Rsbuild plugins, registered after the platform ones
  limits: {                       // local packaging limits; the platform enforces its own
    maxFiles: 20_000,
    maxFileBytes: 100 * 1024 * 1024,
    maxTotalBytes: 1024 * 1024 * 1024,
  },
})

basePath also sets the router basepath and the asset URL prefix. Public files are served under it too: with basePath: '/landing', the file public/images/logo.png is /landing/images/logo.png, and a reference to /images/logo.png fails the build because it would 404 once deployed. Links (<a href>) to paths outside basePath are allowed; they are treated as another site on the same host and are not followed.

What you can and cannot override in rsbuild.config.ts

Other defineConfig keys (for example source.alias, source.define for public constants, tools.rspack) work as usual. The keys below are owned by the platform; setting them fails the build with a message naming the key:

KeyReason
output.distPath, environments.*.output.distPathThe platform reads dist/client and dist/server
output.assetPrefix, server.baseUse basePath
server.publicDirPublic files always come from ./public
output.cleanDistPath: falseStale files would be published
source.define mentioning CLICKMAX_PUBLISH* or process.envCredentials must never reach the browser bundle

Environment

The plugin reads these variables. You normally do not set them yourself; the Clickmax platform does when it runs your build.

VariableEffect
CLICKMAX_SANDBOX=1Development inside the Clickmax sandbox: the dev server listens on port 10143 on all interfaces and enables the editor preview integration.
MXD_STUDIO_ORIGIN_SUFFIXESWhich Clickmax origins may drive the editor preview. Set by the platform.
CLICKMAX_SKIP_VERSION_CHECK=1Skips the once-per-build lookup of the latest plugin version on npm (a warning is printed when a newer one exists; the build never depends on it).
CLICKMAX_BASE_PATHOverrides the authored mount for a production build, including router and asset URLs. Use the basePath option for development.
CLICKMAX_PUBLISH_SOURCE_IDENTITYOptional platform-supplied source fingerprint bound to a publication retry.
CLICKMAX_PUBLISH_ATTEMPT_ID, CLICKMAX_PUBLISH_TOKEN, CLICKMAX_PUBLISH_API_URLPresent only in a build the platform runs to publish. After packaging, the build uploads site.tar.gz; success means the platform accepted it for processing. The three must be set together, and only for rsbuild build.

Without the publish variables a build does no network I/O apart from the version lookup above. Credentials are read in the Node build process only and are never written into the output.

Retrying an upload without rebuilding

If a build succeeded but the upload failed, the artifact stays in dist/clickmax/. With fresh credentials in the environment:

import { publishArtifact } from '@clickmax/rsbuild-plugin'

await publishArtifact() // verifies dist/clickmax/ against the build's own record, then uploads

Retries reuse the original attempt, mount and prepared bytes. Renewing the token is allowed; changing the binding requires a new publication attempt. Do not rerun a publication build to retry an upload. dist/clickmax/status.json records local progress; acceptance is not proof the site is live.

Errors

Every error thrown by the plugin has a stable code and a message that says what to change:

  • ClickmaxConfigError: a configuration conflict, raised before compiling.
  • ClickmaxArtifactError: the build output cannot become a complete site (missing reference, server functions, unsafe file).
  • ClickmaxPublishError: upload failed; stage says where (env, prepare, upload, complete) and retryable whether trying again later makes sense.

Supported toolchain

  • Node.js 24.16 or newer
  • @rsbuild/core ^2.2
  • @tanstack/react-start 1.168.60 or newer (1.x)
  • React 19, Tailwind CSS 4

License

GPL-3.0-only. See LICENSE.

版本与发布记录

@clickmax/rsbuild-plugin 共发布 9 个版本,首次发布于 2026/10/02;过去 12 个月发布了 9 个版本。

版本发布日期距今
1.0.0latest2026/11/064 天前
0.5.22026/11/054 天前
0.5.12026/10/091 个月前
0.5.02026/10/081 个月前
0.4.02026/10/031 个月前
0.2.22026/10/031 个月前

关于 @clickmax/rsbuild-plugin 的常见问题

@clickmax/rsbuild-plugin 是什么?

Clickmax platform integration for Rsbuild: React, Tailwind CSS and TanStack Start with static prerendering, packaged into a publishable site artifact.

如何安装 @clickmax/rsbuild-plugin?

在项目目录运行 npm install @clickmax/rsbuild-plugin,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=19.0.0)、react-dom(>=19.0.0)、tailwindcss(^4.0.0)、@rsbuild/core(^2.2.0)、@tanstack/react-start(>=1.168.60 <2)、@tanstack/react-router(>=1.170.41 <2)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@clickmax/rsbuild-plugin 支持 TypeScript 吗?

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

@clickmax/rsbuild-plugin 支持 ESM 还是 CommonJS?

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

@clickmax/rsbuild-plugin 可以商用吗?

@clickmax/rsbuild-plugin 使用 GPL-3.0-only 许可。强 Copyleft:分发包含该代码的软件时,整个作品需以 GPL-3.0 兼容许可开源,并附带专利与反锁定条款。仅内部使用不触发此义务。以上为概括,不构成法律意见,请以许可原文为准。

@clickmax/rsbuild-plugin 的下载量有多少?

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

@clickmax/rsbuild-plugin 还在维护吗?

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