Skip to content

Commit d4d8ade

Browse files
authored
docs: update options.ssr migration guide (vitejs#20034)
1 parent f32d174 commit d4d8ade

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/changes/this-environment-in-hooks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Affect scope: `Vite Plugin Authors`
1818

1919
## Migration Guide
2020

21-
For the existing plugin to do a quick migration, replace the `options.ssr` argument with `this.environment.name !== 'client'` in the `resolveId`, `load` and `transform` hooks:
21+
For the existing plugin to do a quick migration, replace the `options.ssr` argument with `this.environment.config.consumer === 'server'` in the `resolveId`, `load` and `transform` hooks:
2222

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

3333
if (isSSR) {
3434
// SSR specific logic

0 commit comments

Comments
 (0)