title: React Deploying to AWS S3 production using npm - index.html file as last
body: <p>I have a React app (using React Create App) which I want to upload to production using a script. My production is an AWS S3 bucket. I have added to package.json a "deploy" script as follows:</p>
  
  <pre><code>"scripts": {
      "start": "react-scripts start",
      "build": "react-scripts build",
      "test": "react-scripts test --env=jsdom",
      "eject": "react-scripts eject",
      "deploy": "aws s3 cp ./build s3://app.example.com --recursive --exclude \"*.DS_Store\" --cache-control public,max-age=604800 --profile production-profile"
    },
  </code></pre>
  
  <p>This will updload all the build files to the production bucket. Since the build static files (css, js etc.) get their own hash code they do not get overwritten by each version and that is fine. </p>
  
  <p>The problem I am having is that I don't want the index.html file to be uploaded until AFTER the other files have completed upload. That way, once index.html is overwritten with the latest version the new static files are automatically used. </p>
  
  <p>Any idea how to achieve this? If there is a better script for uploading a react app to S3 would be great.</p>