Skip to content

Instantly share code, notes, and snippets.

@qswitcher
Last active July 25, 2018 02:01
Show Gist options
  • Save qswitcher/8492f8fbf10bcd6e01a9c7bf531bfd55 to your computer and use it in GitHub Desktop.
Save qswitcher/8492f8fbf10bcd6e01a9c7bf531bfd55 to your computer and use it in GitHub Desktop.
version: 0.1
phases:
pre_build:
commands:
- echo Installing source NPM dependencies...
- npm install
build:
commands:
- echo Build started on `date`
- npm run build
post_build:
commands:
# copy the contents of /build to S3
- aws s3 cp --recursive --acl public-read ./build s3://${DeployBucket}/
# set the cache-control headers for service-worker.js to prevent
# browser caching
- >
aws s3 cp --acl public-read
--cache-control="max-age=0, no-cache, no-store, must-revalidate"
./build/service-worker.js s3://${DeployBucket}/
# set the cache-control headers for index.html to prevent
# browser caching
- >
aws s3 cp --acl public-read
--cache-control="max-age=0, no-cache, no-store, must-revalidate"
./build/index.html s3://${DeployBucket}/
# invalidate the CloudFront cache for index.html and service-worker.js
# to force CloudFront to update its edge locations with the new versions
- >
aws cloudfront create-invalidation --distribution-id ${Distribution}
--paths /index.html /service-worker.js
artifacts:
files:
- '**/*'
base-directory: build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment