docs: integrate rsbuild-plugin-pwa for PWA support#3252
docs: integrate rsbuild-plugin-pwa for PWA support#3252
Conversation
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.
Deploying rspress-v2 with
|
| 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 |
There was a problem hiding this comment.
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-pwadependency to the website package. - Enabled
pluginPWA()inrspress.config.tsalongside 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(), |
There was a problem hiding this comment.
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.
| card: 'summary_large_image', | ||
| }, | ||
| }), | ||
| pluginPWA(), |
There was a problem hiding this comment.
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.
| pluginPWA(), | |
| pluginPWA({ | |
| manifest: { | |
| name: 'Rspress', | |
| short_name: 'Rspress', | |
| start_url: '/', | |
| display: 'standalone', | |
| }, | |
| }), |
website/package.json
Outdated
| "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", |
There was a problem hiding this comment.
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.
| "rsbuild-plugin-pwa": "^0.1.1", | |
| "rsbuild-plugin-pwa": "~0.1.1", |
Rsdoctor Bundle Diff AnalysisFound 3 projects in monorepo, 1 project with changes. 📊 Quick Summary
📋 Detailed Reports (Click to expand)📁 nodePath:
📦 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
Summary
Related Issue
#1198
Checklist
What
Integrate
rsbuild-plugin-pwainto the Rspress documentation website to evaluate PWA (Progressive Web App) support.Changes
rsbuild-plugin-pwaas a dev dependency inwebsite/package.jsonpluginPWA()tobuilderConfig.pluginsinwebsite/rspress.config.tsBuild Results
The plugin successfully generates the following PWA artifacts during
rspress build:sw.js(63KB)manifest.webmanifestregister-sw.jsAll 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) referenceregister-sw.jsandmanifest.webmanifestwith relative paths instead of absolute paths, causing 404s. The root cause is thatextractEnvBaseUrl()returns an empty string whenserver.baseis not configured, makingpath.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