universal-react-on-azure icon indicating copy to clipboard operation
universal-react-on-azure copied to clipboard

React server-side rendering / webpack bundling example on Azure.

Universal React on Azure


This an example for running an universal React app on Azure. The following stack is used:

Installation

$ npm install

Ignore any errors about peer dependencies :see_no_evil:

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.