Skip to content
This repository has been archived by the owner on Dec 3, 2020. It is now read-only.

Latest commit

 

History

History
32 lines (19 loc) · 1.93 KB

README.md

File metadata and controls

32 lines (19 loc) · 1.93 KB

UI monorepo setup

This project is using Lerna to manage a monorepo for React apps development.

Create React App v2 with TypeScript (without ejecting!) is used for React applications development and TypeScript compiler tsc (you can also use Babel or Rollup) is used to bundle the @ui/shared package which contains React components shared between two/multiple React apps.

Development

First you need to install the dependencies, by runnig lerna boostrap command, or simply:

yarn setup

Then run yarn start in the root of the monorepo. Lerna will then run start scripts in every package.

yarn start

If everything works ok, any change to components within @ui/shared package will cause tsc to recompile the package (and TS types) and it will be picked up by running CRA dev servers recompiling React applications.

For ease of development you can create additional script for running only one app and shared components package compilation, ie. yarn start:hooks will run start scripts only in @ui/react-app-hooks and @ui/shared packages.

React apps were bootstraped by running npx create-react-app react-app --typescript inside /packages folder and then rm -rf react-app/node_modules react-app/yarn.lock to remove local node_modules and *.lock files.

If you have ideas how to improve this setup please file an issue.

Caveats

  • when running CRA dev server (yarn start) through Lerna you need to reload the opened browser tab sometimes to see the app, but then it sould work without any issues.
  • if you want to run multiple CRA projects simultaneously you need to manualy configure PORT environment variable for each React app, ie. using .env file as described in the official documentation. Otherwise Lerna script will have some issues.