create-static-react-app v1.0.0
@stellar-apps/create-static-react-app
This is an inst template for launching
static hosted React apps on S3 + CloudFront with custom domains.
Installation
This assumes you've already created an inst workspace with inst init [workspace]
cd my-workspace
yarn inst @stellar-apps/create-static-react-appInstallation options
Name- The name of the package you're creating
AWS profile- The name of the AWS profile in your
~/.aws/credentialsfile that you'd like to use to deploy this application
- The name of the AWS profile in your
Domain name [production]- The domain name to launch the
productionversion of your static app on
- The domain name to launch the
Website S3 bucket [production]- default
[value of production Domain name] - The name of the bucket to deploy the static site (HTML files, robots.txt, etc.) into.
- default
Client S3 bucket [production]- default
[Name]-public - The name of the bucket to deploy your client JS, images, etc. into. These are resources that are external to your static application, as in, not HTML files, robots.txt, etc.
- default
Domain name [staging]- default
staging-[Domain name]if[Domain name]is a subdomain, otherwisestaging.[Domain name] - The domain name to launch the
stagingversion of your static app on
- default
Website S3 bucket [staging]- default
[value of staging Domain name] - See
productionabove for description
- default
Client S3 bucket [staging]- default
[value of production Client S3 bucket with '-public' replaced by '-staging-public'] - See
productionabove for description
- default
Inherits code from- Use the spacebar and arrow keys to select libraries already part of your Workspace to inherit code from,
e.g. a
coreorshareddirectory. You will then be able to import these libraries into your application via the alias~[library name]e.g.import {Header} from '~core'
- Use the spacebar and arrow keys to select libraries already part of your Workspace to inherit code from,
e.g. a
Configuring CloudFormation
You should pay special attention to these values in serverless.yml EVERY TIME you create a new app
from this template. This should be the FIRST THING you do after you create an app.
The default template assumes you're using a unique bucket for the public client assets of this application. If you're using a shared bucket that already exists, be sure to delete the
resources.Resources.ClientS3Bucketsection of theserverless.ymlthat gets generated.The default behavior for client buckets is to
retainthem onteardownso as not to accidentally empty a bucket that is in use by other applications. To change this behavior, assuming your bucket is unique, you can change the option forretaintofalseincustom.syncBundle['webpack/client.config.js'].bucketand comment outresources.Resources.ClientS3Bucket.DeletionPolicy.The default behavior for managing ACM certificates is to
retainthem onteardown. This is to prevent encountering errors when you try to remove certificates that are still in use by other applications, e.g. wildcard certificates. To change this behavior, setretaintofalseincustom.certificateManager.retainPay special attention to the
custom.certificateManager.domainslisted to be sure they are exactly the domains you need a certificate for and that they will use the exact same certificate.You will want to glance at the
.env.[stage]files to ensure the properPUBLIC_PATHis defined if you're using a CloudFront distribution in front of your S3 bucket.
Managing the application
Starting the app in the development stage and development NODE_ENV on a local server
cd my-workspace
yarn my-app startStarting the app in the development stage and production NODE_ENV on a local server
cd my-workspace
yarn my-app start productionDeploying the CloudFormation stack to staging stage
Note: You have to use this command before using deploy without a --stack flag
cd my-workspace
yarn my-app deploy --stackDeploying the CloudFormation stack to production stage
Note: You have to use this command before using deploy production without a --stack flag
cd my-workspace
yarn my-app deploy production --stackDeploying the application without changing the CloudFormation stack to staging stage
cd my-workspace
yarn my-app deployDeploying the application without changing the CloudFormation stack to production stage
cd my-workspace
yarn my-app deploy productionBundling the application without uploading the staging stage to S3
cd my-workspace
yarn my-app bundleBundling the application without uploading the production stage to S3
cd my-workspace
yarn my-app bundle productionTearing down the staging CloudFormation stack
This removes your CloudFormation stack and all the resources defined within it. Use with extreme caution.
cd my-workspace
yarn my-app teardownTearing down the production CloudFormation stack
This removes your CloudFormation stack and all the resources defined within it. Use with extreme caution.
cd my-workspace
yarn my-app teardown production7 years ago