Skip to content

Commit

Permalink
docs: complete react rendering configuration (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
aretrace authored Jul 27, 2024
1 parent f8bb384 commit 849f9c0
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,54 @@ createClient({
})
```

Configure react in `vite.config.ts`.

```ts
// vite.config.ts
import pages from '@hono/vite-cloudflare-pages'
import honox from 'honox/vite'
import { defineConfig } from 'vite'
export default defineConfig(({ mode }) => {
if (mode === 'client') {
return {
build: {
rollupOptions: {
input: ['./app/client.ts'],
output: {
entryFileNames: 'static/client.js',
chunkFileNames: 'static/assets/[name]-[hash].js',
assetFileNames: 'static/assets/[name].[ext]'
}
},
emptyOutDir: false
}
}
} else {
return {
ssr: {
external: ['react', 'react-dom']
},
plugins: [honox(), pages()]
}
}
})
```

Adjust `tsconfig.json` jsx factory function option.

```ts
// tsconfig.json
{
"compilerOptions": {
...
"jsxImportSource": "react"
...
}
}

```
## Guides
### Nested Layouts
Expand Down

0 comments on commit 849f9c0

Please sign in to comment.