Skip to content

Commit b85816a

Browse files
david-potgieterjaredpalmer
authored andcommitted
Add Now deployment example (#728)
* Duplicated basic example * Renamed package name * Updated readme for Now * Added post Now build process hook * Tweaked README format and content
1 parent d7c8ece commit b85816a

11 files changed

Lines changed: 169 additions & 0 deletions

File tree

examples/with-now/.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
logs
2+
*.log
3+
npm-debug.log*
4+
.DS_Store
5+
6+
coverage
7+
node_modules
8+
build
9+
public/static
10+
.env.*.local

examples/with-now/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Razzle Now Deployment example
2+
3+
## How to use
4+
5+
Download the example [or clone the whole project](https://github.com/jaredpalmer/razzle.git):
6+
7+
```bash
8+
curl https://codeload.github.com/jaredpalmer/razzle/tar.gz/master | tar -xz --strip=2 razzle-master/examples/with-now
9+
cd with-now
10+
```
11+
12+
### Install it and run locally:
13+
14+
```bash
15+
yarn install
16+
yarn start
17+
```
18+
19+
### Setup Now:
20+
21+
[Now](https://zeit.co/now) manages app deployments with a [desktop](https://zeit.co/download) app or [CLI](https://zeit.co/download#now-cli).
22+
23+
* You can download either the [desktop](https://zeit.co/download) (ships and installs the CLI as well) or just the [CLI](https://zeit.co/download#now-cli)
24+
* Or install only the CLI directly using: `npm install -g now`
25+
* Create a Now [account](https://zeit.co/signup)
26+
* Authenticate in the desktop app or CLI with `now login`
27+
28+
### Deploy:
29+
30+
* Deploy using `now` in the root of your app.
31+
* Open your [Dashboard](https://zeit.co/dashboard/deployments) and test your deployment
32+
* Note: on the free plan your deployment and logs will be **_publicly visible_**
33+
34+
#### Additional Configuration:
35+
36+
* Additional build, deployment, and config steps available: [Zeit/Now](https://zeit.co/now#frequently-asked-questions)
37+
38+
## Idea behind the example
39+
40+
This is a basic example of how to use razzle and deploy to [Now](https://zeit.co/now).

examples/with-now/package.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "razzle-examples-with-now",
3+
"version": "2.4.0",
4+
"license": "MIT",
5+
"scripts": {
6+
"start": "razzle start",
7+
"build": "razzle build",
8+
"test": "razzle test --env=jsdom",
9+
"start:prod": "NODE_ENV=production node build/server.js",
10+
"now-start": "yarn start:prod"
11+
},
12+
"dependencies": {
13+
"express": "^4.15.2",
14+
"react": "^16.0.0",
15+
"react-dom": "^16.0.0"
16+
},
17+
"devDependencies": {
18+
"razzle": "^2.4.0"
19+
}
20+
}
32.2 KB
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
User-agent: *
2+

examples/with-now/src/App.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
body {
2+
margin: 0;
3+
padding: 0;
4+
font-family: -apple-system,
5+
BlinkMacSystemFont,
6+
"Segoe UI",
7+
Helvetica,
8+
Arial,
9+
sans-serif,
10+
"Apple Color Emoji",
11+
"Segoe UI Emoji",
12+
"Segoe UI Symbol";
13+
}

examples/with-now/src/App.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import './App.css';
2+
3+
import React from 'react';
4+
const App = () => <div>Welcome to Razzle.</div>;
5+
6+
export default App;

examples/with-now/src/App.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import App from './App';
2+
import React from 'react';
3+
import ReactDOM from 'react-dom';
4+
5+
describe('<App />', () => {
6+
test('renders without exploding', () => {
7+
const div = document.createElement('div');
8+
ReactDOM.render(<App />, div);
9+
});
10+
});

examples/with-now/src/client.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react';
2+
import { hydrate } from 'react-dom';
3+
import App from './App';
4+
5+
hydrate(<App />, document.getElementById('root'));
6+
7+
if (module.hot) {
8+
module.hot.accept();
9+
}

examples/with-now/src/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import express from 'express';
2+
import app from './server';
3+
4+
if (module.hot) {
5+
module.hot.accept('./server', function() {
6+
console.log('🔁 HMR Reloading `./server`...');
7+
});
8+
console.info('✅ Server-side HMR Enabled!');
9+
}
10+
11+
const port = process.env.PORT || 3000;
12+
13+
export default express()
14+
.use((req, res) => app.handle(req, res))
15+
.listen(port, function(err) {
16+
if (err) {
17+
console.error(err);
18+
return;
19+
}
20+
console.log(`> Started on port ${port}`);
21+
});

0 commit comments

Comments
 (0)