Deploying Web Application

A step by step guide on how to deploy React Razzle App on AWS

Add razzle config

// razzle.config.js

'use strict';
module.exports = {
  options: {
    buildType: 'serverless'
  },
  modifyPaths({
    paths,
  }) {
    paths.prodAppServerIndexJs = path.join(paths.appSrc, 'index.prod');
    return paths;
  },
  modifyWebpackConfig({
    env: {
      target,
      dev,
    },
    webpackConfig,
    paths,
  }) {
    if (target === 'node') {
      if (!dev) {
        webpackConfig.entry.server = [paths.prodAppServerIndexJs];
      }
    }
    return webpackConfig;
  },
};

Modify src/server.js like so:

Add this to src/index.prod.js

Add serverless-http dependency

Build the Razzle project

Init cdk app

Add razzle-cdk dependencies in razzle-cdk directory

Add razzle-cdk/bin/razzle-cdk.ts

Add razzle-cdk/lib/helpers.ts

Add razzle-cdk/lib/razzle-cdk-stack.ts

Bootstrap and deploy

Last updated

Was this helpful?