Razzle Preact Example
How to use
Download the example or clone the whole project:
curl https://codeload.github.com/jaredpalmer/razzle/tar.gz/master | tar -xz --strip=2 razzle-master/examples/with-preactcd with-preact
Install it and run:
yarn installyarn start
Idea behind the example
This shows how to setup Preact with Razzle.
Here is a list of changes from Razzle's base template:
- Install
babel-plugin-transform-react-jsx
as a devDependency. - Extend Razzle's babel config with a custom
.babelrc
- Install
preact
andpreact-render-to-string
- Remove
react
,react-dom
,react-router-dom
entirely - Update
server.js
to usepreact-render-to-string
'srender
function. Also remove the<div id="root">
element from our html template since Preact can render to the body.