Skip to content
Martin Kruger edited this page Jan 7, 2021 · 5 revisions

Welcome to the contentful-gatsby-components wiki!

yarc, Running the project locally:

For linking this project as a local dependency

Intro:

We need to be able to make modifications to this library while it is being used in the main Gatsby/CMS repos. You would typically do this with yarn link, however it has proven to be problematic. https://github.com/dadoagency/contentful-gatsby-components/issues/6

We are now experimenting with yalc to link the project.

Links:

npm: https://www.npmjs.com/package/yalc

GitHub: https://github.com/whitecolor/yalc

Steps:

Step 1: Install yalc:

Install yalc.

Using NPM:

npm i yalc -g

Using Yarn:

yarn global add yalc

Step 2: Publish this project locally:

Add this project as your published local dependency.

Run the following of the root folder of this project, not the Gatsby/CMS repo.

yalc publish

Step 3: Link the project in Gatsby/CMS repo:

Link the this project locally.

In your Gatsby/CMS root folder, run:

yalc link @dadoagency/contentful-gatsby-components

Step 4: Update changes in this project

You need to run a command(s) for the changes to reflect.

You can either do this manually or use a watch mode we have setup.

Manual:
  1. Run yalc publish in the dependency repo after you've made changes.
  2. Run yalc update in the Gatsby/CMS repo.

Alternatively, you can simply:

  1. Run yalc push in the dependency repo after you've made changes.
Automatic:
  1. Run yarn run watch-yalc (This will run: nodemon -x 'yalc push --changed')