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
4 changes: 4 additions & 0 deletions guide/api-environment-frameworks.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ if (isRunnableDevEnvironment(server.environments.ssr)) {
[SSR セットアップガイド](/guide/ssr#setting-up-the-dev-server)で説明されているように、ミドルウェアモードに設定された Vite サーバーがあるとして、Environment API を使って SSR ミドルウェアを実装してみましょう。エラー処理は省略します。

```js
import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { createServer } from 'vite'

const __dirname = path.dirname(fileURLToPath(import.meta.url))
const server = await createServer({
server: { middlewareMode: true },
appType: 'custom',
Expand Down
15 changes: 12 additions & 3 deletions guide/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,12 @@ export default defineConfig({
ビルド時には、エントリーポイントとして複数の `.html` ファイルを指定するだけです:

```js twoslash [vite.config.js]
import { resolve } from 'path'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { defineConfig } from 'vite'

const __dirname = dirname(fileURLToPath(import.meta.url))

export default defineConfig({
build: {
rollupOptions: {
Expand All @@ -134,9 +137,12 @@ HTML ファイルの場合、Vite は `rollupOptions.input` オブジェクト
::: code-group

```js twoslash [vite.config.js(単一エントリー)]
import { resolve } from 'path'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { defineConfig } from 'vite'

const __dirname = dirname(fileURLToPath(import.meta.url))

export default defineConfig({
build: {
lib: {
Expand All @@ -162,9 +168,12 @@ export default defineConfig({
```

```js twoslash [vite.config.js(複数エントリー)]
import { resolve } from 'path'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { defineConfig } from 'vite'

const __dirname = dirname(fileURLToPath(import.meta.url))

export default defineConfig({
build: {
lib: {
Expand Down
Loading