Skip to content

Instantly share code, notes, and snippets.

@stevehanson
Last active February 27, 2019 19:00
Show Gist options
  • Save stevehanson/ff70ca54fc2aadfe67f3e3e730161350 to your computer and use it in GitHub Desktop.
Save stevehanson/ff70ca54fc2aadfe67f3e3e730161350 to your computer and use it in GitHub Desktop.
Circle CI config for Create React App
version: 2
jobs:
build:
docker:
- image: circleci/node:10.11.0
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "yarn.lock" }}
- run:
name: Setup Dependencies
command: yarn install
- save_cache:
key: dependency-cache-{{ checksum "yarn.lock" }}
paths:
- ./node_modules
- run:
name: Run Test
command: yarn test
@stevehanson
Copy link
Author

yarn.lock seems a bit safer to me, just since it represents exactly which dependencies to download.

At least in my case, there are times when the package.json doesn't change, but the yarn.lock does, since we have a dependency on another internal GitHub repo that isn't versioned. When we upgrade that dependency via yarn upgrade ..., the package.json stays unchanged, but the lockfile changes, pointing to the latest git commit of that dependency.

You could always watch both I think with dependency-cache-{{ checksum "yarn.lock" }}-{{ checksum "package.json" }} to be extra safe. Hope that helps!

@SViccari
Copy link

super helpful, thank you! 🌸

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment