Skip to content

Instantly share code, notes, and snippets.

@meech-ward
Created June 27, 2022 18:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save meech-ward/c0ee31fc2256c7fab6d494121071e53c to your computer and use it in GitHub Desktop.
Save meech-ward/c0ee31fc2256c7fab6d494121071e53c to your computer and use it in GitHub Desktop.
Deploy React App to S3 with Custom Domain notes

https://youtu.be/7djMZ5OTG_E


The bucket policy. Remember to replace sammeechward.xyz with your bucket's name:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Statement1",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::sammeechward.xyz/*"
        }
    ]
}

Sync script. Remember to replace sammeechward.xyz with your bucket's name:

aws s3 sync ./dist 's3://sammeechward.xyz/'

My full package.json file for my vite app:

{
  "name": "vite-project",
  "private": true,
  "version": "0.0.0",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "sync": "aws s3 sync --profile 'meech-ward' ./dist 's3://sammeechward.xyz/'",
    "preview": "vite preview"
  },
  "dependencies": {
    "axios": "^0.27.2",
    "react": "^18.0.0",
    "react-dom": "^18.0.0",
    "react-router-dom": "6"
  },
  "devDependencies": {
    "@types/react": "^18.0.0",
    "@types/react-dom": "^18.0.0",
    "@vitejs/plugin-react": "^1.3.0",
    "vite": "^2.9.9"
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment