DEV Community

Discussion on: Docker setup for yarn workspaces

Collapse
 
jonlauridsen profile image
Jon Lauridsen • Edited

Thanks, I enjoy reading monorepo setups, there are many valid approaches, and little details and pitfalls.

In this case, how would you use local libraries? If your app requires several local libraries out of many.

Also, a small note, I believe docker-compose has been folded into docker compose. It doesn’t really matter to your article, but sometimes it’s nice to install one less tool :)

Collapse
 
siddharthvenkatesh profile image
Siddharth Venkatesh

Hey,
The simplest way I can think of to a local library to the app is to add the library as dependency in the app's package.json and make sure the library is compiled before you start the app.
I've added this step in the repo
If you see the package.json scripts section, I'm just adding a build step for lib before starting/building the apps.

"scripts": {
    "admin": "yarn build:lib && yarn workspace admin start",
    "product": "yarn build:lib && yarn workspace product start",
    "build:admin": "yarn build:lib && yarn workspace admin build",
    "build:product": "yarn build:lib && yarn workspace product build",
    "build:lib": "yarn workspace lib build"
  }
Enter fullscreen mode Exit fullscreen mode

I believe we can extend this approach for multiple libraries.

Not sure if this is the best approach, but it works :)