From 91c10ad95b2153d239bbaa815deeb7ea7139609d Mon Sep 17 00:00:00 2001 From: Mars Hall Date: Wed, 18 Apr 2018 10:13:56 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9A=20clarify=20how=20this=20is=20"two?= =?UTF-8?q?=20npm=20projects"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6afc632..3f468dc 100755 --- a/README.md +++ b/README.md @@ -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 +```