An open API service indexing awesome lists of open source software.

https://github.com/do-community/sample-yarn-lerna-monorepo


https://github.com/do-community/sample-yarn-lerna-monorepo

Last synced: 11 months ago
JSON representation

Awesome Lists containing this project

README

          

# Lerna monorepo example

This is an example monorepo that uses lerna. There are two packages in the repo: `workspace-a`, and `workspace-b`. Both packages start HTTP servers using `yarn serve`, each returning different responses.

## Local Testing

1. Start at the repo root
1. Run `yarn install` to install all dependencies
* Note that `package.json` contains a `postinstall` script that runs `lerna bootstrap`.
* This instruct yarn to run `lerna bootstrap` after `yarn install` has finished. This allows lerna to install any required dependencies and also link the `workspace-a` and `workspace-b` packages. By doing this as part of the install step, App Platform can cache the dependencies installed by lerna.
* Important: if you do not configure a similar `postinstall` command, you will need to manually run `lerna bootstrap`.
1. Change into either workspace directory:
* `cd packages/workspace-a`; or
* `cd packages/workspace-b`
1. Run the example build command: `yarn build`
1. Start the server: `yarn serve`

## Deploying to App Platform

1. Select your git repo
1. Keep the source directory set to the default, `/`
1. Set the build command to:
```
yarn bootstrap
cd packages/workspace-b
yarn build
```
1. Set the run command to:
```
cd packages/workspace-b
yarn serve
```