1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Update preact example

This commit is contained in:
Tim Neutkens 2018-01-31 10:07:52 +01:00
parent 6db44f8058
commit f0703f8e13
3 changed files with 7 additions and 32 deletions

View file

@ -1,16 +1,3 @@
module.exports = { const withPreact = require('@zeit/next-preact')
webpack: function (config, { dev }) {
// For the development version, we'll use React.
// Because, it supports react hot loading and so on.
if (dev) {
return config
}
config.resolve.alias = { module.exports = withPreact()
'react': 'preact-compat/dist/preact-compat',
'react-dom': 'preact-compat/dist/preact-compat'
}
return config
}
}

View file

@ -7,16 +7,10 @@
"start": "NODE_ENV=production node server.js" "start": "NODE_ENV=production node server.js"
}, },
"dependencies": { "dependencies": {
"module-alias": "^2.0.0", "@zeit/next-preact": "0.0.4",
"next": "latest", "next": "latest",
"preact": "^7.2.0", "preact": "8.2.7",
"preact-compat": "^3.14.0", "preact-compat": "3.18.0"
"react": "^16.0.0",
"react-dom": "^16.0.0"
}, },
"license": "ISC", "license": "ISC"
"devDependencies": {
"react": "~15.6.1",
"react-dom": "~15.6.1"
}
} }

View file

@ -1,13 +1,7 @@
const port = parseInt(process.env.PORT, 10) || 3000 const port = parseInt(process.env.PORT, 10) || 3000
const dev = process.env.NODE_ENV !== 'production' const dev = process.env.NODE_ENV !== 'production'
const moduleAlias = require('module-alias')
// For the development version, we'll use React. require('@zeit/next-preact/alias')()
// Because, it support react hot loading and so on.
if (!dev) {
moduleAlias.addAlias('react', 'preact-compat')
moduleAlias.addAlias('react-dom', 'preact-compat')
}
const { createServer } = require('http') const { createServer } = require('http')
const { parse } = require('url') const { parse } = require('url')