Commit 4dd4df10 authored by Rafael Almeida's avatar Rafael Almeida Committed by Joe Haddad

[using-preact] Update example to Preact X (#9079)

* Update preact example with Preact X

* Update README
parent 0886a123
# Hello World example
# Preact example
## How to use
......@@ -43,4 +43,5 @@ This example uses [Preact](https://github.com/developit/preact) instead of React
Here's how we did it:
- Use `next.config.js` to customize our webpack config to support [preact-compat](https://github.com/developit/preact-compat)
- Use `next.config.js` to customize our webpack config by aliasing React to `preact/compat`
- Use `server.js` to make our server use Preact by aliasing React to `preact/compat`
const withPreact = require('@zeit/next-preact')
module.exports = {
webpack: function (config) {
config.resolve.alias = {
...config.resolve.alias,
react: 'preact/compat',
react$: 'preact/compat',
'react-dom': 'preact/compat',
'react-dom$': 'preact/compat'
}
module.exports = withPreact()
return config
}
}
......@@ -7,10 +7,14 @@
"start": "NODE_ENV=production node server.js"
},
"dependencies": {
"@zeit/next-preact": "0.1.0",
"module-alias": "2.2.2",
"next": "latest",
"preact": "8.2.7",
"preact-compat": "3.18.0"
"preact": "10.0.0",
"preact-render-to-string": "5.0.7"
},
"license": "ISC"
"license": "ISC",
"devDependencies": {
"react": "16.10.2",
"react-dom": "16.10.2"
}
}
const port = parseInt(process.env.PORT, 10) || 3000
const dev = process.env.NODE_ENV !== 'production'
const moduleAlias = require('module-alias')
require('@zeit/next-preact/alias')()
moduleAlias.addAliases({
react: 'preact/compat',
'react-dom': 'preact/compat'
})
const { createServer } = require('http')
const { parse } = require('url')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment