Skip to content

Commit

Permalink
refactor!: merge PreviewServerForHook into PreviewServer type
Browse files Browse the repository at this point in the history
  • Loading branch information
MH4GF committed Sep 2, 2023
1 parent 687335d commit 11dab7f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
11 changes: 2 additions & 9 deletions guide/api-javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,7 @@ import { preview } from 'vite'
## `PreviewServer`

```ts
interface PreviewServer extends PreviewServerForHook {
resolvedUrls: ResolvedServerUrls
}
```

## `PreviewServerForHook`

```ts
interface PreviewServerForHook {
interface PreviewServer {
/**
* 解決された vite config オブジェクト
*/
Expand All @@ -229,6 +221,7 @@ interface PreviewServerForHook {
httpServer: http.Server
/**
* Vite が CLI に表示する解決済みURL
* サーバーがリッスンする前は null
*/
resolvedUrls: ResolvedServerUrls | null
/**
Expand Down
2 changes: 1 addition & 1 deletion guide/api-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ Vite プラグインは Vite 特有の目的を果たすフックを提供する

- **:** `(server: PreviewServerForHook) => (() => void) | void | Promise<(() => void) | void>`
- **種類:** `async`, `sequential`
- **参照:** [PreviewServerForHook](./api-javascript#previewserverforhook)
- **参照:** [PreviewServer](./api-javascript#previewserver)

[`configureServer`](/guide/api-plugin.html#configureserver) と同じですがプレビューサーバ用です。`configureServer` と同様に、`configurePreviewServer` フックは他のミドルウェアがインストールされる前に呼び出されます。他のミドルウェアをインストールした**後に**ミドルウェアをインジェクトしたい場合は、`configurePreviewServer` から関数を返すことで、内部のミドルウェアがインストールされた後に呼び出されるようにすることができます:

Expand Down

0 comments on commit 11dab7f

Please sign in to comment.