Skip to content
Merged
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
4 changes: 2 additions & 2 deletions changes/this-environment-in-hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Vite 6 以前は `client` と `ssr` という 2 つの環境しか利用でき

## 移行ガイド

既存のプラグインを素早くマイグレーションするには、`resolveId`、`load`、`transform` フックの `options.ssr` 引数を `this.environment.name !== 'client'` に置き換えてください:
既存のプラグインを素早くマイグレーションするには、`resolveId`、`load`、`transform` フックの `options.ssr` 引数を `this.environment.config.consumer === 'server'` に置き換えてください:

```ts
import { Plugin } from 'vite'
Expand All @@ -28,7 +28,7 @@ export function myPlugin(): Plugin {
name: 'my-plugin',
resolveId(id, importer, options) {
const isSSR = options.ssr // [!code --]
const isSSR = this.environment.name !== 'client' // [!code ++]
const isSSR = this.environment.config.consumer === 'server' // [!code ++]

if (isSSR) {
// SSR 固有のロジック
Expand Down