Universal React on Azure
This an example for running an universal React app on Azure. The following stack is used:
- React @ 0.14.0-beta1 for improved server-side redering
- React Router @ 1.0.0-beta2 for better API on server-side
- Express
- Babel for transpiling JSX, ES6/7
- Webpack for bundling
- Webpack Dev Server for local development
- React Hot Loader
- Redux
- Material Design Lite CSS Framework
Installation
$ npm install
Ignore any errors about peer dependencies ๐
Running Dev Server
$ npm run dev
Building and Running Production Server
$ npm run start:prod
Deploying on Azure
Set environment variables on Azure
NODE_ENV = production
NODE_PATH = ./src
BABEL_DISABLE_CACHE = 1
Custom Deployment Script
To bundle the javascripts on Azure during deployment, a custom deployment script is needed that runs the required commands.
Scaffold a script using azure-cli
$ azure site deploymentscript --node
Add the bundle command (here: npm run build
) after npm install
, see deploy.sh.