Skip to content

feat: allow plugin to specify apply property#5620

Merged
chenjiahan merged 2 commits intomainfrom
plugin_apply_0717
Jul 18, 2025
Merged

feat: allow plugin to specify apply property#5620
chenjiahan merged 2 commits intomainfrom
plugin_apply_0717

Conversation

@chenjiahan
Copy link
Copy Markdown
Member

Summary

Allow plugin to specify the apply property:

  • '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.

const servePlugin: RsbuildPlugin = {
  name: 'serve-plugin',
  apply: 'serve',
  setup(api) {
    // ...
  },
};

Checklist

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

Copilot AI review requested due to automatic review settings July 17, 2025 14:49
@netlify
Copy link
Copy Markdown

netlify Bot commented Jul 17, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit 6029603
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/68790fbc8653230008cdd38b
😎 Deploy Preview https://deploy-preview-5620--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 64 (🔴 down 10 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

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 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 RsbuildPluginApply type and optional apply property to the RsbuildPlugin interface
  • 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

Comment thread packages/core/src/pluginManager.ts
@chenjiahan chenjiahan merged commit 5514cbe into main Jul 18, 2025
12 checks passed
@chenjiahan chenjiahan deleted the plugin_apply_0717 branch July 18, 2025 02:19
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