Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions guide/api-environment-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,19 @@ Vite サーバーには共有プラグインパイプラインがありますが

## フックを使用して新しい環境を登録する {#registering-new-environments-using-hooks}

プラグインは、`config` フックに新しい環境を追加できます(たとえば、[RSC](https://react.dev/blog/2023/03/22/react-labs-what-we-have-been-working-on-march-2023#react-server-components) 用の個別のモジュールグラフを作成する場合など):
プラグインは、`config` フックに新しい環境を追加できます。例えば、[RSC サポート](/plugins/#vitejs-plugin-rsc) では、`react-server` 条件を含む個別のモジュールグラフを持つために追加の環境を使用します:

```ts
config(config: UserConfig) {
config.environments.rsc ??= {}
return {
environments: {
rsc: {
resolve: {
conditions: ['react-server', ...defaultServerConditions],
},
},
},
}
}
```

Expand All @@ -48,8 +56,16 @@ Vite サーバーには共有プラグインパイプラインがありますが

```ts
configEnvironment(name: string, options: EnvironmentOptions) {
// rsc 環境に "workerd" 条件を追加
if (name === 'rsc') {
options.resolve.conditions = // ...
return {
resolve: {
conditions: ['workerd'],
},
}
}
}
```
```

## `hotUpdate` フック {#the-hotupdate-hook}
Expand Down
1 change: 1 addition & 0 deletions guide/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ HTML ファイルは、Vite プロジェクトの[中心](/guide/#index-html-and
- Vue JSX のサポート: [@vitejs/plugin-vue-jsx](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx)
- React のサポート: [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react)
- SWC を利用している React のサポート: [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react-swc)
- [React サーバーコンポーネント(RSC)](https://react.dev/reference/rsc/server-components)のサポート: [@vitejs/plugin-rsc](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-rsc)

詳しくは[プラグインガイド](/plugins/)を確認してください。

Expand Down
10 changes: 10 additions & 0 deletions plugins/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ esbuild と Babel を使用し、小さなパッケージフットプリント

開発中は Babel を SWC に置き換えます。プロダクションビルド時には、プラグインを使用する場合は SWC+esbuild、それ以外は esbuild を使用します。非標準の React 拡張を必要としない大きなプロジェクトでは、コールドスタートやホットモジュールリプレースメント(HMR)が大幅に高速化されます。

### [@vitejs/plugin-rsc](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-rsc)

Vite はこのプラグインを通して [React サーバーコンポーネント(RSC)](https://react.dev/reference/rsc/server-components)をサポートしています。このプラグインは、React フレームワークが RSC 機能を統合するために使用できる低レベルのプリミティブを提供する [Environment API](/guide/api-environment) を利用しています。以下を実行してミニマルなスタンドアロン RSC アプリケーションを試すことができます:

```bash
npm create vite@latest -- --template rsc
```

詳しくは [プラグインドキュメント](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-rsc) をお読みください。

### [@vitejs/plugin-legacy](https://github.com/vitejs/vite/tree/main/packages/plugin-legacy)

本番環境向けにレガシーブラウザーのサポートを提供します。
Expand Down