diff --git a/examples/using-nerv/README.md b/examples/using-nerv/README.md new file mode 100644 index 0000000000000..0156310fdb352 --- /dev/null +++ b/examples/using-nerv/README.md @@ -0,0 +1,44 @@ +[![Deploy to now](https://deploy.now.sh/static/button.svg)](https://deploy.now.sh/?repo=https://github.com/zeit/next.js/tree/master/examples/using-nerv) + +# Hello World example + +## How to use + +### Using `create-next-app` + +Download [`create-next-app`](https://github.com/segmentio/create-next-app) to bootstrap the example: + +``` +npm i -g create-next-app +create-next-app --example using-nerv using-nerv-app +``` + +### Download manually + +Download the example [or clone the repo](https://github.com/zeit/next.js): + +```bash +curl https://codeload.github.com/zeit/next.js/tar.gz/canary | tar -xz --strip=2 next.js-canary/examples/using-nerv +cd using-nerv +``` + +Install it and run: + +```bash +npm install +npm run dev +``` + +Deploy it to the cloud with [now](https://zeit.co/now) ([download](https://zeit.co/download)) + +```bash +now +``` + +## The idea behind the example + +This example uses [Nerv](https://nerv.aotu.io/) instead of React. It's a "blazing fast React alternative, compatible with IE8 and React 16". Here we've customized Next.js to use Nerv instead of React. + +Here's how we did it: + +* Use `next.config.js` to customize our webpack config to support [Nerv](https://nerv.aotu.io/) diff --git a/examples/using-nerv/next.config.js b/examples/using-nerv/next.config.js new file mode 100644 index 0000000000000..c709c9832d43d --- /dev/null +++ b/examples/using-nerv/next.config.js @@ -0,0 +1,16 @@ +module.exports = { + 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 = { + react: 'nervjs', + 'react-dom': 'nervjs' + } + + return config + } +} diff --git a/examples/using-nerv/package.json b/examples/using-nerv/package.json new file mode 100644 index 0000000000000..15cded8d5ce53 --- /dev/null +++ b/examples/using-nerv/package.json @@ -0,0 +1,21 @@ +{ + "name": "using-nerv", + "version": "1.0.0", + "scripts": { + "dev": "node server.js", + "build": "next build", + "start": "NODE_ENV=production node server.js" + }, + "dependencies": { + "module-alias": "^2.0.0", + "next": "latest", + "nervjs": "^1.2.4", + "react": "^16.0.0", + "react-dom": "^16.0.0" + }, + "license": "ISC", + "devDependencies": { + "react": "~15.6.1", + "react-dom": "~15.6.1" + } +} diff --git a/examples/using-nerv/pages/about.js b/examples/using-nerv/pages/about.js new file mode 100644 index 0000000000000..6c501fbd81e18 --- /dev/null +++ b/examples/using-nerv/pages/about.js @@ -0,0 +1,5 @@ +import React from 'react' + +export default () => ( +