-
Notifications
You must be signed in to change notification settings - Fork 61
feat: ssg rspress example #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Please also create a PR on |
|
@fiorin Have an errors in console, not sure is it an issue, |
Discussed already with @VladyslavZinchenko, but here some context on the PR. The example is the default implementation from Rspress documentation: here with a Zephyr custom plugin and the SSG flag enabled on the config file:
The issue with SSG flag was multiple Zephyr triggering on build:
And after upload the assets, multiple served URL generated, but only the last one proper loading. So the main goal of the implementation was solve the multiple trigger issue, so the tweak in the custom Zephyr plugin:
|
Claude finished @fiorin's task in 1m 56s —— View job Code Review: Rspress SSG ExamplePurpose: Adds an Rspress SSG example with a custom Rsbuild plugin that prevents multiple Zephyr build triggers during SSG compilation. Todo List:
Review Findings
Specific Code Improvements1. Type Safety Fix (rspress.config.ts:5-13): interface RsbuildAPI {
modifyRspackConfig: (callback: (config: RspackConfig) => Promise<void>) => void;
}
interface RspackConfig {
name?: string;
[key: string]: any;
}
const zephyrRsbuildPlugin = () => ({
name: "zephyr-rspress-ssg-plugin",
setup(api: RsbuildAPI) {
api.modifyRspackConfig(async (config: RspackConfig) => {
// Only apply Zephyr to web builds to prevent multiple SSG triggers
if (config.name === "web") {
await withZephyr()(config);
}
});
},
}); 2. Extract Plugin to Separate File: // plugins/zephyr-rsbuild-plugin.ts
import { withZephyr } from "zephyr-rspack-plugin";
export interface RsbuildAPI {
modifyRspackConfig: (callback: (config: RspackConfig) => Promise<void>) => void;
}
export interface RspackConfig {
name?: string;
[key: string]: any;
}
export const createZephyrRsbuildPlugin = () => ({
name: "zephyr-rspress-ssg-plugin",
setup(api: RsbuildAPI) {
api.modifyRspackConfig(async (config: RspackConfig) => {
if (config.name === "web") {
await withZephyr()(config);
}
});
},
}); 3. Enhanced Documentation (README.md): # Rspress SSG with Zephyr Integration
This example demonstrates how to integrate Zephyr with Rspress SSG (Static Site Generation).
## Zephyr Integration
Due to Rspress SSG creating multiple build pipelines, a custom Rsbuild plugin is used to prevent multiple Zephyr deployments:
```typescript
// The plugin only applies Zephyr to the 'web' build configuration
config.name === "web" && (await withZephyr()(config)); This prevents the SSG from triggering multiple authentication prompts and asset uploads. Setup...existing setup instructions... Known Issues
Overall Quality Score: 6/10Strengths:
Areas for Improvement:
Top 3 Next Steps:
|
add an example using Rspress for server static site generator
to make Rspress to work with Zephyr is needed need a custom plugin, but enabling SSG triggers multiple times the build, so it is needed to proper check with thread is the proper one, so a tweak in the plugin does the work: