This repo is responsible for user experience in the CBRE Dev Listings App. Pages served by this application are pre-rendered by a compute cluster and delivered as static html. We also deliver a client-side bundle of javascript that boots a react.js applicaiton on top of the static html.
Static html is rendered using react-dom-server's renderToString() method on the server. On page load we use react-dom's hydrate() method to boot the application.
Typically devlopers do not have to think about where their code is being executed as the same components are used to render server side and client side.
This project includes a build script which will pre-transpile things that need to be babelized, as well as produce the client side bundle.
To run a build:
-
npm install
-
npm run build
- there is an optional
build-id
flag that will create the rendered js in a directory names for that build id. usage:npm run build -- -build-id=<my-build-id>
(note the wierd syntax)
This will create a /dist
folder containing the transpiled version of this code as well as the client side bundle.
Prerequisites:
Install node js TLS release (https://nodejs.org/en/)
Clone this repository
-
npm install
-
npm run build
-
npm start
touch ./config/local.yaml
- in local.yaml copy paste:
staticAssets: host: localhost port: 8000 path: client bundleFilename: client.bundle.js stylesheetFilename: styles.css
- start server as above
- in a seperate terminal run
npx webpack-dev-server
Unit tests expect jest framework.
To run: jest
at project root.
To run in watch mode:
brew update
brew install watchman
jest --watch
Note: You'll only have to install watchman once