Skip to content

Conversation

hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Sep 1, 2025

Description

For example, this allows other plugin to control RscPluginOptions via its own config hook:

import { defineConfig } from "vite";
import rsc from "@vitejs/plugin-rsc";

export default defineConfig({
  plugins: [
    {
       name: 'rsc-ssg',
       config(_config, env) {
          return {
             appType: env.isPreview ? "mpa" : undefined,
             rsc: {
               serverHandler: env.isPreview ? false : undefined,
               ...
             }
          }
       }
    },
    rsc({
       // ... instead of config here ...
    }),
  ],
})

@hi-ogawa hi-ogawa marked this pull request as ready for review September 1, 2025 06:15
@hi-ogawa hi-ogawa requested a review from Copilot September 1, 2025 06:17
Copy link

@Copilot 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 adds support for configuring RSC plugin options through the top-level rsc property in Vite's user config, allowing other plugins to set options via the config hook.

  • Adds support for UserConfig.rsc: RscPluginOptions to allow configuration through Vite's config system
  • Refactors buildApp hook handling to use object format with conditional execution based on useBuildAppHook option
  • Updates example configurations to demonstrate the new configuration approach

Reviewed Changes

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

File Description
packages/plugin-rsc/src/plugin.ts Implements config merging for config.rsc and refactors buildApp hook handling
packages/plugin-rsc/examples/starter-cf-single/vite.config.ts Demonstrates new rsc config property usage
packages/plugin-rsc/examples/ssg/vite.config.ts Migrates from function-based to object-based config and uses new rsc property
packages/plugin-rsc/README.md Documents the new configuration option

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@hi-ogawa hi-ogawa merged commit 07a64c2 into main Sep 1, 2025
28 checks passed
@hi-ogawa hi-ogawa deleted the 09-01-feat_rsc_support_userconfig.rsc_rscpluginoptions_ branch September 1, 2025 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add empty builder.buildApp to workaround @cloudflare/vite-plugin build conflict Support overriding RscPluginOptions via user config

1 participant