machine:
  node:
    version: 8
dependencies:
  override:
    - npm install
test:
  override:
    - echo "test"
checkout:
  post:
    - aws configure set preview.cloudfront true
    - aws configure set preview.create-invalidation true    
deployment:
  prod:
    branch: master
    commands:
      - npm run build
      - aws s3 sync public s3://chocolate-free.com --delete --cache-control "max-age=3153600"
      - aws cloudfront create-invalidation --cli-input-json "{\"DistributionId\":\"$CLOUD_FRONT_INSTANCE\",\"InvalidationBatch\":{\"Paths\":{\"Quantity\":1,\"Items\":[\"/*\"]},\"CallerReference\":\"$(date +%s)\"}}" &> /dev/null

machine:
  node:
    version: 8
dependencies:
  override:
    - npm install
test:
  override:
    - echo "test"
checkout:
  post:
    - aws configure set preview.cloudfront true
    - aws configure set preview.create-invalidation true    
deployment:
  prod:
    branch: master
    commands:
      - npm run build
      - aws s3 sync public s3://chocolate-free.com --delete --cache-control "max-age=3153600" --exclude 'sw.js' --exclude 'index.html'
      - aws cloudfront create-invalidation --cli-input-json "{\"DistributionId\":\"$CLOUD_FRONT_INSTANCE\",\"InvalidationBatch\":{\"Paths\":{\"Quantity\":1,\"Items\":[\"/*\"]},\"CallerReference\":\"$(date +%s)\"}}" &> /dev/null

Exclude sw.js and index.html from cache
Exclude sw.js and index.html from cache