0

I have a React app which is running on AWS S3. Here is my script for building & deploying;

"scripts": {
  "predeploy": "npm run build-css && NODE_PATH=src react-scripts build",
  "deploy": "aws s3 sync build/ s3://example.com",
}

However, this is very annoying that I should wait for the "predeploy" then "deploy". How do I achieve it with just one command line?

Can I just join all in one? So for example,

"deploy": "npm run build-css && NODE_PATH=src react-scripts build && aws s3 sync build/ s3://example.com"
hood
  • 79
  • 3
  • 9
  • For other details regarding CRA deployment to AWS S3/CloudFront: https://stackoverflow.com/questions/54655204/steps-to-deploy-a-react-app-on-s3-with-cloudfront-while-managing-caching – CharlieH Apr 26 '19 at 13:52

1 Answers1

1

Yes you can!

If you want to only sync certain files (i.e. create a whitelist so you don't deploy .map files etc.) you can do something like:

"deploy": "npm run build-css && NODE_PATH=src react-scripts build && aws s3 sync build/ s3://example.com --ecluse '*' --include 'yourFileName.js' --include 'yourOtherFileName.css'"