Skip to content

docs: integrate rsbuild-plugin-pwa for PWA support#3252

Draft
SoonIter wants to merge 3 commits intomainfrom
syt-vibe-kanban/b24a-website-rsbuild
Draft

docs: integrate rsbuild-plugin-pwa for PWA support#3252
SoonIter wants to merge 3 commits intomainfrom
syt-vibe-kanban/b24a-website-rsbuild

Conversation

@SoonIter
Copy link
Copy Markdown
Member

@SoonIter SoonIter commented Mar 24, 2026

Summary

Related Issue

#1198

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

What

Integrate rsbuild-plugin-pwa into the Rspress documentation website to evaluate PWA (Progressive Web App) support.

Changes

  • Added rsbuild-plugin-pwa as a dev dependency in website/package.json
  • Added pluginPWA() to builderConfig.plugins in website/rspress.config.ts

Build Results

The plugin successfully generates the following PWA artifacts during rspress build:

File Description
sw.js (63KB) Workbox-based service worker that precaches all build assets
manifest.webmanifest Web app manifest (auto-generated from package.json)
register-sw.js Service worker registration script with update/offline-ready events

All HTML pages have <script defer src="..."> and <link rel="manifest"> tags injected.

Known Issue

A relative path bug was discovered in the plugin: nested pages (e.g., /guide/advanced/overview-page) reference register-sw.js and manifest.webmanifest with relative paths instead of absolute paths, causing 404s. The root cause is that extractEnvBaseUrl() returns an empty string when server.base is not configured, making path.posix.join("", "file.js") produce "file.js" instead of "/file.js".

This has been reported upstream: s-r-x/rsbuild-plugin-pwa#2

This PR was written using Vibe Kanban


Add rsbuild-plugin-pwa to the website to evaluate PWA capabilities.
The plugin generates a service worker, manifest, and registration script,
though relative path issues exist for nested pages.
Copilot AI review requested due to automatic review settings March 24, 2026 08:30
@SoonIter SoonIter changed the title 尝试给 website 接入 rsbuild-plugin-pwa 这个包,用 npm run build 查看产物,并看看它是否真的 work (vibe-kanban) chore(website): integrate rsbuild-plugin-pwa for PWA support Mar 24, 2026
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Mar 24, 2026

Deploying rspress-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1b2aec2
Status: ✅  Deploy successful!
Preview URL: https://bea67d52.rspress-v2.pages.dev
Branch Preview URL: https://syt-vibe-kanban-b24a-website.rspress-v2.pages.dev

View logs

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR attempts to enable PWA support for the website by integrating rsbuild-plugin-pwa into the Rspress build so the build output can be inspected to verify PWA behavior.

Changes:

  • Added rsbuild-plugin-pwa dependency to the website package.
  • Enabled pluginPWA() in rspress.config.ts alongside other Rsbuild plugins.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

File Description
website/rspress.config.ts Imports and registers pluginPWA() in the Rsbuild plugin chain.
website/package.json Adds rsbuild-plugin-pwa dependency for the website build.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

card: 'summary_large_image',
},
}),
pluginPWA(),
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enabling a Service Worker/PWA plugin unconditionally can negatively impact local development and debugging due to aggressive caching and offline behavior. Consider conditionally enabling PWA only for production builds (or explicitly disabling it in dev) if the plugin supports such an option.

Copilot uses AI. Check for mistakes.
card: 'summary_large_image',
},
}),
pluginPWA(),
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling pluginPWA() with no configuration makes the produced manifest/service worker behavior dependent on plugin defaults, which can make it harder to verify whether it 'really works' and can lead to missing app metadata (name/icons/theme colors). Consider adding explicit configuration (e.g., manifest fields/icons/output filenames) so the build artifacts and runtime behavior are deterministic and reviewable.

Suggested change
pluginPWA(),
pluginPWA({
manifest: {
name: 'Rspress',
short_name: 'Rspress',
start_url: '/',
display: 'standalone',
},
}),

Copilot uses AI. Check for mistakes.
"react-dom": "^19.2.4",
"rsbuild-plugin-google-analytics": "^1.0.5",
"rsbuild-plugin-open-graph": "^1.1.2",
"rsbuild-plugin-pwa": "^0.1.1",
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using ^ with a 0.x dependency can still pull in breaking changes (since 0.* is treated as unstable by semver). Consider pinning to an exact version (or using ~0.1.1) to avoid unexpected build/runtime changes when installing dependencies.

Suggested change
"rsbuild-plugin-pwa": "^0.1.1",
"rsbuild-plugin-pwa": "~0.1.1",

Copilot uses AI. Check for mistakes.
@SoonIter SoonIter changed the title chore(website): integrate rsbuild-plugin-pwa for PWA support docs: integrate rsbuild-plugin-pwa for PWA support Mar 24, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 24, 2026

Rsdoctor Bundle Diff Analysis

Found 3 projects in monorepo, 1 project with changes.

📊 Quick Summary
Project Total Size Change
node 12.5 MB +17.3 KB (0.1%)
node_md 1.6 MB 0
web 16.2 MB 0
📋 Detailed Reports (Click to expand)

📁 node

Path: website/doc_build/diff-rsdoctor/node/rsdoctor-data.json

📌 Baseline Commit: 4d854ba1a0 | PR: #3253

Metric Current Baseline Change
📊 Total Size 12.5 MB 12.4 MB +17.3 KB (0.1%)
📄 JavaScript 0 B 0 B 0
🎨 CSS 0 B 0 B 0
🌐 HTML 12.5 MB 12.4 MB +17.3 KB (0.1%)
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: node Bundle Diff

Generated by Rsdoctor GitHub Action

Work around rsbuild-plugin-pwa generating relative paths for
register-sw.js and manifest.webmanifest by setting server.base to "/".
See: s-r-x/rsbuild-plugin-pwa#2
@SoonIter SoonIter marked this pull request as draft March 24, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants