feat: allow plugin to specify apply property#5620
Merged
chenjiahan merged 2 commits intomainfrom Jul 18, 2025
Merged
Conversation
✅ Deploy Preview for rsbuild ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces an apply property to Rsbuild plugins that allows conditional application based on the execution context (serve vs build). This enables plugins to specify whether they should run during development/preview servers ('serve') or during the build process ('build').
- Adds
RsbuildPluginApplytype and optionalapplyproperty to theRsbuildPlugininterface - Implements conditional plugin initialization logic that filters plugins based on the current action
- Includes comprehensive E2E tests to verify plugins are applied correctly in different contexts
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/types/plugin.ts | Adds type definition and optional apply property to plugin interface |
| packages/core/src/provider/initConfigs.ts | Updates plugin initialization to pass full context instead of just API getter |
| packages/core/src/pluginManager.ts | Implements conditional plugin application logic based on context action |
| e2e/cases/plugin-api/plugin-apply/src/index.js | Test application entry point |
| e2e/cases/plugin-api/plugin-apply/src/index.css | Test application styles |
| e2e/cases/plugin-api/plugin-apply/rsbuild.config.ts | Test configuration with serve and build specific plugins |
| e2e/cases/plugin-api/plugin-apply/index.test.ts | E2E tests verifying conditional plugin application |
This was referenced Jul 18, 2025
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Allow plugin to specify the
applyproperty:'serve': Apply the plugin when starting the dev server or preview server.'build': Apply the plugin during build.If not specified, the plugin will be applied during both serve and build.
Checklist