-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from preactjs/refactor/migrate-to-prerender-pl…
…ugin refactor: Migrate off of Vike and to `@preact/preset-vite`'s prerender functionality
- Loading branch information
Showing
21 changed files
with
95 additions
and
348 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,4 +30,4 @@ | |
"typescript": "^5.0.0" | ||
}, | ||
"prettier": "prettier-config-rschristian" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { render } from 'preact'; | ||
|
||
import preactLogo from './assets/preact.svg'; | ||
import './style.css'; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { LocationProvider, Router, Route, hydrate, prerender as ssr } from 'preact-iso'; | ||
|
||
import { Header } from './components/Header.jsx'; | ||
import { Home } from './pages/Home/index.jsx'; | ||
import { NotFound } from './pages/_404.jsx'; | ||
import './style.css'; | ||
|
||
export function App() { | ||
return ( | ||
<LocationProvider> | ||
<Header /> | ||
<main> | ||
<Router> | ||
<Route path="/" component={Home} /> | ||
<Route default component={NotFound} /> | ||
</Router> | ||
</main> | ||
</LocationProvider> | ||
); | ||
} | ||
|
||
if (typeof window !== 'undefined') { | ||
hydrate(<App />, document.getElementById('app')); | ||
} | ||
|
||
export async function prerender(data) { | ||
return await ssr(<App {...data} />); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { defineConfig } from 'vite'; | ||
import preact from '@preact/preset-vite'; | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [ | ||
preact({ | ||
prerender: { | ||
enabled: true, | ||
renderTarget: '#app', | ||
additionalPrerenderRoutes: ['/404'], | ||
}, | ||
}), | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 8 additions & 2 deletions
10
templates/ssr/vite.config.js → templates/config/prerender/vite.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
import { defineConfig } from 'vite'; | ||
import preact from '@preact/preset-vite'; | ||
import ssr from 'vike/plugin'; | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [preact(), ssr({ prerender: true })], | ||
plugins: [ | ||
preact({ | ||
prerender: { | ||
enabled: true, | ||
renderTarget: '#app', | ||
}, | ||
}), | ||
], | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.