diff --git a/examples/with-polka/.gitignore b/examples/with-polka/.gitignore new file mode 100644 index 000000000..13d409785 --- /dev/null +++ b/examples/with-polka/.gitignore @@ -0,0 +1,10 @@ +logs +*.log +npm-debug.log* +.DS_Store + +coverage +node_modules +build +public/static +.env.*.local \ No newline at end of file diff --git a/examples/with-polka/README.md b/examples/with-polka/README.md new file mode 100644 index 000000000..66ae94e06 --- /dev/null +++ b/examples/with-polka/README.md @@ -0,0 +1,22 @@ +# Razzle Polka Example + +## How to use + +Download the example [or clone the whole project](https://github.com/jaredpalmer/razzle.git): + +```bash +curl https://codeload.github.com/jaredpalmer/razzle/tar.gz/master | tar -xz --strip=2 razzle-master/examples/with-polka +cd with-polka +``` + +Install it and run: + +```bash +yarn install +yarn start +``` + +## Idea behind the example + +An example of how to use a custom, express middleware-compatible server like [polka](https://github.com/lukeed/polka) with razzle. It satisfies the entry points +`src/index.js` for the server and and `src/client.js` for the browser. HMR works for server-side changes too by creating new instances of the polka server handler. diff --git a/examples/with-polka/package.json b/examples/with-polka/package.json new file mode 100644 index 000000000..25b429b81 --- /dev/null +++ b/examples/with-polka/package.json @@ -0,0 +1,20 @@ +{ + "name": "razzle-examples-with-polka", + "version": "0.8.12", + "license": "MIT", + "scripts": { + "start": "razzle start", + "build": "razzle build", + "test": "razzle test --env=jsdom", + "start:prod": "NODE_ENV=production node build/server.js" + }, + "dependencies": { + "polka": "^0.3.4", + "react": "^16.2.0", + "react-dom": "^16.2.0", + "serve-static": "^1.13.2" + }, + "devDependencies": { + "razzle": "^0.8.12" + } +} diff --git a/examples/with-polka/public/favicon.ico b/examples/with-polka/public/favicon.ico new file mode 100644 index 000000000..46bceb8c7 Binary files /dev/null and b/examples/with-polka/public/favicon.ico differ diff --git a/examples/with-polka/public/robots.txt b/examples/with-polka/public/robots.txt new file mode 100644 index 000000000..54fb98911 --- /dev/null +++ b/examples/with-polka/public/robots.txt @@ -0,0 +1,2 @@ +User-agent: * + diff --git a/examples/with-polka/src/App.css b/examples/with-polka/src/App.css new file mode 100644 index 000000000..e26469b20 --- /dev/null +++ b/examples/with-polka/src/App.css @@ -0,0 +1,13 @@ +body { + margin: 0; + padding: 0; + font-family: -apple-system, + BlinkMacSystemFont, + "Segoe UI", + Helvetica, + Arial, + sans-serif, + "Apple Color Emoji", + "Segoe UI Emoji", + "Segoe UI Symbol"; +} diff --git a/examples/with-polka/src/App.js b/examples/with-polka/src/App.js new file mode 100644 index 000000000..d8840a547 --- /dev/null +++ b/examples/with-polka/src/App.js @@ -0,0 +1,6 @@ +import './App.css'; + +import React from 'react'; +const App = () =>