Skip to content

Commit f18601f

Browse files
Merge pull request #3 from ace-of-aces/prettier-diffs
Prettier diffs with syntax highlighting
2 parents 32e6bf2 + 9fe60bc commit f18601f

File tree

5 files changed

+252
-252
lines changed

5 files changed

+252
-252
lines changed

v1/advanced/server-side-rendering.mdx

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,12 @@ When creating this file, be sure to add anything that's missing from your `app.j
154154

155155
Next, we need to update our Vite configuration to build our new `ssr.js` file. We can do this by adding a `ssr` property to Laravel's Vite plugin configuration in our `vite.config.js`file.
156156

157-
```diff
157+
```js
158158
export default defineConfig({
159159
plugins: [
160160
laravel({
161161
input: ['resources/css/app.css', 'resources/js/app.js'],
162-
+ ssr: 'resources/js/ssr.js',
162+
ssr: 'resources/js/ssr.js', // [!code ++]
163163
refresh: true,
164164
}),
165165
// ...
@@ -171,11 +171,11 @@ export default defineConfig({
171171

172172
Next, let's update the `build` script in our `package.json` file to also build our new `ssr.js` file.
173173

174-
```diff
174+
```json
175175
"scripts": {
176176
"dev": "vite",
177-
- "build": "vite build"
178-
+ "build": "vite build && vite build --ssr"
177+
"build": "vite build" // [!code --]
178+
"build": "vite build && vite build --ssr" // [!code ++]
179179
},
180180
```
181181

@@ -215,62 +215,62 @@ Since your website is now being server-side rendered, you can instruct <VueSpeci
215215
// No changes required
216216
```
217217

218-
```diff Vue 3
219-
- import { createApp, h } from 'vue'
220-
+ import { createSSRApp, h } from 'vue'
221-
import { createInertiaApp } from '@inertiajs/vue3'
218+
```js Vue 3
219+
import { createApp, h } from 'vue' // [!code --]
220+
import { createSSRApp, h } from 'vue' // [!code ++]
221+
import { createInertiaApp } from '@inertiajs/vue3'
222222

223-
createInertiaApp({
224-
resolve: name => {
225-
const pages = import.meta.glob('./Pages/**/*.vue', { eager: true })
226-
return pages[`./Pages/${name}.vue`]
227-
},
228-
setup({ el, App, props, plugin }) {
229-
- createApp({ render: () => h(App, props) })
230-
+ createSSRApp({ render: () => h(App, props) })
231-
.use(plugin)
232-
.mount(el)
233-
},
234-
})
223+
createInertiaApp({
224+
resolve: name => {
225+
const pages = import.meta.glob('./Pages/**/*.vue', { eager: true })
226+
return pages[`./Pages/${name}.vue`]
227+
},
228+
setup({ el, App, props, plugin }) {
229+
createApp({ render: () => h(App, props) }) // [!code --]
230+
createSSRApp({ render: () => h(App, props) }) // [!code ++]
231+
.use(plugin)
232+
.mount(el)
233+
},
234+
})
235235
```
236236

237-
```diff React icon="react"
238-
import { createInertiaApp } from '@inertiajs/react'
239-
- import { createRoot } from 'react-dom/client'
240-
+ import { hydrateRoot } from 'react-dom/client'
241-
242-
createInertiaApp({
243-
resolve: name => {
244-
const pages = import.meta.glob('./Pages/**/*.jsx', { eager: true })
245-
return pages[`./Pages/${name}.jsx`]
246-
},
247-
setup({ el, App, props }) {
248-
- createRoot(el).render(<App {...props} />)
249-
+ hydrateRoot(el, <App {...props} />)
250-
},
251-
})
237+
```js React icon="react"
238+
import { createInertiaApp } from '@inertiajs/react'
239+
import { createRoot } from 'react-dom/client' // [!code --]
240+
import { hydrateRoot } from 'react-dom/client' // [!code ++]
241+
242+
createInertiaApp({
243+
resolve: name => {
244+
const pages = import.meta.glob('./Pages/**/*.jsx', { eager: true })
245+
return pages[`./Pages/${name}.jsx`]
246+
},
247+
setup({ el, App, props }) {
248+
createRoot(el).render(<App {...props} />) // [!code --]
249+
hydrateRoot(el, <App {...props} />) // [!code ++]
250+
},
251+
})
252252
```
253253

254-
```diff Svelte icon="s"
255-
import { svelte } from '@sveltejs/vite-plugin-svelte'
256-
import laravel from 'laravel-vite-plugin'
257-
import { defineConfig } from 'vite'
258-
259-
export default defineConfig({
260-
plugins: [
261-
laravel.default({
262-
input: ['resources/css/app.css', 'resources/js/app.js'],
263-
ssr: 'resources/js/ssr.js',
264-
refresh: true,
265-
}),
266-
- svelte(),
267-
+ svelte({
268-
+ compilerOptions: {
269-
+ hydratable: true,
270-
+ },
271-
+ }),
272-
],
273-
})
254+
```js Svelte icon="s"
255+
import { svelte } from '@sveltejs/vite-plugin-svelte'
256+
import laravel from 'laravel-vite-plugin'
257+
import { defineConfig } from 'vite'
258+
259+
export default defineConfig({
260+
plugins: [
261+
laravel.default({
262+
input: ['resources/css/app.css', 'resources/js/app.js'],
263+
ssr: 'resources/js/ssr.js',
264+
refresh: true,
265+
}),
266+
svelte(), // [!code --]
267+
svelte({ // [!code ++:5]
268+
compilerOptions: {
269+
hydratable: true,
270+
},
271+
}),
272+
],
273+
})
274274
```
275275

276276
</CodeGroup>
@@ -279,21 +279,21 @@ Since your website is now being server-side rendered, you can instruct <VueSpeci
279279

280280
You'll also need to enable hydration in your `app.js` file:
281281

282-
```diff
283-
import { createInertiaApp } from '@inertiajs/svelte'
284-
285-
createInertiaApp({
286-
resolve: name => {
287-
const pages = import.meta.glob('./Pages/**/*.svelte', { eager: true })
288-
return pages[`./Pages/${name}.svelte`]
289-
},
290-
- setup({ el, App, props }) {
291-
- new App({ target: el, props })
292-
- },
293-
+ setup({ el, App }) {
294-
+ new App({ target: el, hydrate: true })
295-
+ },
296-
})
282+
```js
283+
import { createInertiaApp } from '@inertiajs/svelte'
284+
285+
createInertiaApp({
286+
resolve: name => {
287+
const pages = import.meta.glob('./Pages/**/*.svelte', { eager: true })
288+
return pages[`./Pages/${name}.svelte`]
289+
},
290+
setup({ el, App, props }) { // [!code --:3]
291+
new App({ target: el, props })
292+
},
293+
setup({ el, App }) { // [!code ++:3]
294+
new App({ target: el, hydrate: true })
295+
},
296+
})
297297
```
298298

299299
</SvelteSpecific>

0 commit comments

Comments
 (0)