📚 clarify how this is "two npm projects"

This commit is contained in:
Mars Hall
2018-04-18 10:13:56 -07:00
committed by GitHub
parent 047761bfd5
commit 91c10ad95b

View File

@@ -10,13 +10,15 @@ To deploy a frontend-only React app, use the static-site optimized
## Design Points
A combo of two npm projects, the backend server and the frontend UI. So there are two `package.json` configs and thereforce two places to run `npm` commands:
A combo of two npm projects, the backend server and the frontend UI. So there are two `package.json` configs and thereforce [two places to run `npm` commands](#user-content-local-development):
1. [`package.json`](package.json) for [Node server](server/) & [Heroku deploy](https://devcenter.heroku.com/categories/deployment)
* `heroku-postbuild` script compiles the webpack bundle during deploy
* `cacheDirectories` includes `react-ui/node_modules/` to optimize build time
2. [`react-ui/package.json`](react-ui/package.json) for [React web UI](react-ui/)
1. [**Node server**](server/): [`./package.json`](package.json)
* [deployed automatically](https://devcenter.heroku.com/categories/deployment) via heroku/nodejs buildpack
2. [**React UI**](react-ui/): [`react-ui/package.json`](react-ui/package.json)
* generated by [create-react-app](https://github.com/facebookincubator/create-react-app)
* deployed via build hooks in the Node server's [`./package.json`](package.json)
* module cache configured by `cacheDirectories`
* bundling via `heroku-postbuild` hook
Includes a minimal [Node Cluster](https://nodejs.org/docs/latest-v8.x/api/cluster.html) [implementation](server/index.js) to parallelize the single-threaded Node process across the available CPU cores.
@@ -81,7 +83,12 @@ If an app was previously deployed with [create-react-app-buildpack](https://gith
## Local Development
### Run the API Server
Because this app is made of two npm projects, there are two places to run `npm` commands:
1. **Node API server** at the root `./`
1. **React UI** in `react-ui/` directory.
### Run the API server
In a terminal:
@@ -93,6 +100,12 @@ npm install
npm start
```
#### Install new npm packages for Node
```bash
npm install package-name --save
```
### Run the React UI
@@ -110,3 +123,12 @@ npm install
# Start the server
npm start
```
#### Install new npm packages for React UI
```bash
# Always change directory, first
cd react-ui/
npm install package-name --save
```