Skip to content

Instantly share code, notes, and snippets.

@dev-dafab
Last active August 23, 2020 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dev-dafab/9c7a8656f12cce38fb2f1aebe3cd28f4 to your computer and use it in GitHub Desktop.
Save dev-dafab/9c7a8656f12cce38fb2f1aebe3cd28f4 to your computer and use it in GitHub Desktop.
monorepo

Javascript

  • Init a Javascript/typescript/nodejs monorepo
npm install -g json
yarn config set workspaces-experimental true
mkdir -p monorepo/packages && cd monorepo && yarn init -y

# Config package.json
# root of monorepo is not meant to be publish
json -I -f package.json -e 'this.private=true'
json -I -f package.json -e 'this.version=undefined'
json -I -f package.json -e 'this.scripts={"lerna": "lerna"}'
json -I -f package.json -e 'this.scripts={"clean": "lerna run clean --stream --parallel"}'
json -I -f package.json -e 'this.scripts={"build": "lerna run build --stream --parallel"}'
json -I -f package.json -e 'this.scripts={"lint": "lerna run lint --stream --parallel"}'
json -I -f package.json -e 'this.scripts={"test": "lerna run test --stream --parallel"}'
# set workspaces directory
json -I -f package.json -e 'this.workspaces=["packages/*"]'
yarn add lerna -D -W

# config lerna.json
echo "{}" >> lerna.json
json -I -f lerna.json -e 'this.packages=["packages/*"]'
json -I -f lerna.json -e 'this.version="independant"'
json -I -f lerna.json -e 'this.npmClient="yarn"'
json -I -f lerna.json -e 'this.useWorkspaces=true'
# 1. navigate in the monorepo root folder

yarn add prettier prettier-plugin-pkg prettier-plugin-organize-imports -D -W
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment