https://github.com/jacob-ebey/preact-webpack-prerender
POC of pre-rendering Preact applications via a webpack plugin using preact-iso.
https://github.com/jacob-ebey/preact-webpack-prerender
preact webpack5 wmr
Last synced: about 1 month ago
JSON representation
POC of pre-rendering Preact applications via a webpack plugin using preact-iso.
- Host: GitHub
- URL: https://github.com/jacob-ebey/preact-webpack-prerender
- Owner: jacob-ebey
- Created: 2020-12-21T03:16:34.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2020-12-22T05:11:23.000Z (over 4 years ago)
- Last Synced: 2025-04-01T20:23:38.983Z (about 2 months ago)
- Topics: preact, webpack5, wmr
- Language: JavaScript
- Homepage: https://jacob-ebey.js.org/preact-webpack-prerender/
- Size: 248 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Preact Webpack Prerender
POC of pre-rendering Preact applications via a webpack plugin using preact-iso.
[Example](https://jacob-ebey.js.org/preact-webpack-prerender/)
## How it works
Within `webpack.config.js` there is a list of paths defined at the top that is passed onto the `webpack/prerender-plugin.js` that looks like:
```js
const paths = ["/", "/about"];
//..........
new PreactPrerenderPlugin({
paths,
});
```The prerender plugin taps the `afterEmit` hook and uses the CJS assets, along with a cjs build of preact-iso to write html files out to the public directory. The node require cache is cleared of any non `node_module` requires between builds when in watch mode keeping your pre-rendered HTML in sync for local dev.