Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created September 8, 2021 09:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save velotiotech/26f86e4dfcb32eb1a6f624f08d3a362a to your computer and use it in GitHub Desktop.
Save velotiotech/26f86e4dfcb32eb1a6f624f08d3a362a to your computer and use it in GitHub Desktop.
#assuming you are in your react app directory
mkdir /tmp/s3uploads
cp -ar build/static /tmp/s3uploads/
cd /tmp/s3uploads
#add gzip encoding to all the files
gzip -9 `find ./ -type f`
#remove .gz extension from compressed files
for i in `find ./ -type f`
do
mv $i ${i%.*}
done
#sync your files to s3 static bucket and mention that these files are compressed with gzip encoding
#so that browser will not treat them as regular files
aws s3 --region $AWSREGION sync . s3://${S3_STATIC_BUCKET}/static/ --content-encoding gzip --delete --sse
cd -
rm -rf /tmp/s3uploads
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment